How to apply multiple currencies by one cBot?

jennifer1978bgf since: 22 Jan 2023;

  22 Jan 2023, 05:30
How to apply multiple currencies by one cBot?

Dear Spotware,

How to apply multiple currencies by one cBot?

I have tried the code below, even different currencies get opened, the price is not correct.

Can someone help?


        [Parameter("Vol", DefaultValue = 10000)]
        public int Vol { get; set; }

        protected override void OnStart()
        {
            Symbol symbol_1 = MarketData.GetSymbol("USDJPY");
            Symbol symbol_2 = MarketData.GetSymbol("EURUSD");
            Symbol symbol_3 = MarketData.GetSymbol("GBPUSD");

            var result =

            PlaceLimitOrder(TradeType.Buy, symbol_1, Vol, Symbol.Ask - 15 * Symbol.PipSize, "BU", 30, 15);
            PlaceLimitOrder(TradeType.Buy, symbol_2, Vol, Symbol.Ask - 15 * Symbol.PipSize, "BE", 30, 15);           
            PlaceLimitOrder(TradeType.Buy, symbol_3, Vol, Symbol.Ask - 15 * Symbol.PipSize, "BG", 30, 15);           

            if (!result.IsSuccessful) Print("Error: ", result.Error);
             Stop();
        }
    }
}

PanagiotisChar's avatar

PanagiotisChar since: 15 Sep 2022;

  23 Jan 2023, 09:23

Hi there,

What do you expect this code to do and what does it do instead? I don't understand why do you use the current symbol's Ask price as a target price.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Cofounder and Chief Technologist at Aieden Technologies

jennifer1978bgf since: 22 Jan 2023;

  23 Jan 2023, 15:16
RE: So how can I change the target price for each symbol? Thanks.

PanagiotisChar said:

Hi there,

What do you expect this code to do and what does it do instead? I don't understand why do you use the current symbol's Ask price as a target price.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

PanagiotisChar's avatar

PanagiotisChar since: 15 Sep 2022;

  24 Jan 2023, 14:42

Hi there,

See below

            PlaceLimitOrder(TradeType.Buy, symbol_1, Vol, symbol_1.Ask - 15 * Symbol.PipSize, "BU", 30, 15);
            PlaceLimitOrder(TradeType.Buy, symbol_2, Vol, symbol_2.Ask - 15 * Symbol.PipSize, "BE", 30, 15);           
            PlaceLimitOrder(TradeType.Buy, symbol_3, Vol, symbol_3.Ask - 15 * Symbol.PipSize, "BG", 30, 15);           

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Cofounder and Chief Technologist at Aieden Technologies

jennifer1978bgf since: 22 Jan 2023;

  24 Jan 2023, 20:01
RE: But the 2nd and 3rd LimitOrder changed to be MarketOrder, why?

PanagiotisChar said:

Hi there,

See below

            PlaceLimitOrder(TradeType.Buy, symbol_1, Vol, symbol_1.Ask - 15 * Symbol.PipSize, "BU", 30, 15);
            PlaceLimitOrder(TradeType.Buy, symbol_2, Vol, symbol_2.Ask - 15 * Symbol.PipSize, "BE", 30, 15);           
            PlaceLimitOrder(TradeType.Buy, symbol_3, Vol, symbol_3.Ask - 15 * Symbol.PipSize, "BG", 30, 15);           

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

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 UnderTest2 : Robot
    {
        [Parameter(DefaultValue = "USDJPY")]
        public string symbol_1 { get; set; }
        
        [Parameter(DefaultValue = "EURUSD")]
        public string symbol_2 { get; set; }
        
        [Parameter(DefaultValue = "GBPUSD")]
        public string symbol_3 { get; set; }
  
        [Parameter("Vol", DefaultValue = 10000)]
        public int Vol { get; set; }
        
        public double targetPrice_1 { get; set; }
        public double targetPrice_2 { get; set; }
        public double targetPrice_3 { get; set; }
        
        ///////////////////////////////////////////////////////////////////////////////////////////////

        protected override void OnStart()
        {
            Symbol symbol_1 = MarketData.GetSymbol("USDJPY");
            Symbol symbol_2 = MarketData.GetSymbol("EURUSD");
            Symbol symbol_3 = MarketData.GetSymbol("GBPUSD");

            var result =

            PlaceLimitOrder(TradeType.Buy, symbol_1, Vol, Symbol.Ask - 15 * Symbol.PipSize, "BU", 30, 15);
            PlaceLimitOrder(TradeType.Buy, symbol_2, Vol, Symbol.Ask - 15 * Symbol.PipSize, "BE", 30, 15);  
            PlaceLimitOrder(TradeType.Buy, symbol_3, Vol, Symbol.Ask - 15 * Symbol.PipSize, "BG", 30, 15);         

            if (!result.IsSuccessful) Print("Error: ", result.Error);
             Stop();
        }
    }
}

jennifer1978bgf since: 22 Jan 2023;

  25 Jan 2023, 08:15
My purpose is not to add those so many currencies/instances/symbols on the Start cBot click, I just want click once and all the other currencies/instances/symbols can place a LimitOrder, how to do this?

PanagiotisChar said:

Hi there,

See below

            PlaceLimitOrder(TradeType.Buy, symbol_1, Vol, symbol_1.Ask - 15 * Symbol.PipSize, "BU", 30, 15);
            PlaceLimitOrder(TradeType.Buy, symbol_2, Vol, symbol_2.Ask - 15 * Symbol.PipSize, "BE", 30, 15);           
            PlaceLimitOrder(TradeType.Buy, symbol_3, Vol, symbol_3.Ask - 15 * Symbol.PipSize, "BG", 30, 15);           

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

PanagiotisChar's avatar

PanagiotisChar since: 15 Sep 2022;

  25 Jan 2023, 10:33

Hi there,

It seems you made no changes to the code. See my responses above.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Cofounder and Chief Technologist at Aieden Technologies