open trade on one pair when a certain value is reached on a other pair

10 Jan 2017, 18:27open trade on one pair when a certain value is reached on a other pair#1
9570239posts: 2since: 08 Dec 2014


I can imagine that my question has been asked before but i could not find it on the forum.

i would love to have cbot that opens a trade when i certain level has been reached on a othere pair.

to be exact i give an accemple:

let s say i want to go long cadjpy but i only want to do this when usdjpy has reached 114.00. 

is there a cbot that handles this?

if this is not the right forum or topic... be gentle :-) i am new here


10 Jan 2017, 22:53#2
lucianposts: 185since: 26 Dec 2015

You can start with this:


using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class cBot : Robot
        [Parameter("USDJPY price", DefaultValue = 114.0)]
        public double price { get; set; }
        MarketSeries usdjpy;
        protected override void OnStart()
            var timeFrame = MarketSeries.TimeFrame;
            usdjpy = MarketData.GetSeries("USDJPY", timeFrame);

        protected override void OnBar()
            int index = MarketSeries.Close.Count - 2;
            int index1 = usdjpy.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]);

            if (usdjpy.Close[index1] > price)
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, "Label", 10, 10);