Open two opposite positions at every new candle bar
Created at 23 Jul 2022, 17:16
Open two opposite positions at every new candle bar
23 Jul 2022, 17:16
Please could someone help me with code to open two(2) opposite positions(i.e short & Long position) simultaneously at the open of every new candle and to set take profit(TP) 50 pips on both positions. Thanks
Replies
bakosadiq
08 Apr 2023, 07:12
RE: Hello
profitstreet.trade said:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals; namespace cAlgo.Robots { [Robot(AccessRights = AccessRights.None)] public class TwoSides : Robot { [Parameter(DefaultValue = "TwoSides")] public string BotName { get; set; } [Parameter("StopLoss in pips", DefaultValue = 0.00)] public int StopLoss { get; set; } [Parameter("TakeProfit in pips", DefaultValue = 50)] public int TakeProfit { get; set; } [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1000, MinValue = 1000, Step = 1000)] public double Quantity { get; set; } protected override void OnStart() { Print("CBot Started "); } protected override void OnBar() { ExecuteMarketOrder(TradeType.Buy,SymbolName,Quantity,BotName,StopLoss,TakeProfit,"MyBot"); ExecuteMarketOrder(TradeType.Sell,SymbolName,Quantity,BotName,StopLoss,TakeProfit,"MyBot"); } protected override void OnStop() { Print("Bot Stopped "); } } }
Thanks alot. sorry 4 d late reply
@bakosadiq
profitstreet.trade
05 Aug 2022, 06:37
Hello
@profitstreet.trade