cBot dont open position

cBot dont open position
14 Feb 2018, 20:25
Hi,
In the code below, after losing or win trade he dont open new position. Anyone can give any suggestion?
Thank you
protected override void OnStart() { Positions.Closed += OnPositionsClosedBuySymbol1; ExecuteBuyStrategySymbol1(); } (...) private void OnPositionsClosedBuySymbol1(PositionClosedEventArgs args) { var Symbol1MarketData = MarketData.GetSymbol(Symbol1); var myPositionsSymbol1 = Positions.FindAll(LabelSymbol1, Symbol1MarketData); var Symbol1Bid = Math.Round(Symbol1MarketData.Bid, 6); var Symbol1Ask = Math.Round(Symbol1MarketData.Ask, 6); double Symbol1Spread = Math.Round((Symbol1MarketData.Ask - Symbol1MarketData.Bid) / Symbol1MarketData.PipSize, 3); var PositionBuySymbol1 = args.Position; var loopControlSymbol1 = true; if (PositionBuySymbol1.Label != LabelSymbol1 || PositionBuySymbol1.SymbolCode != Symbol1) return; if (PositionBuySymbol1.GrossProfit > 0) { ExecuteBuyStrategySymbol1(); } else { while (loopControlSymbol1 == true) { if (myPositionsSymbol1.Length <= (MaxOpenTradesSymbol1 - 1) && Symbol1Spread <= MaxSpreadSymbol1) { ExecuteOrderBuySymbol1((int)PositionBuySymbol1.Volume * 2, PositionBuySymbol1.TradeType); loopControlSymbol1 = false; } } } }
Replies
DelFonseca
15 Feb 2018, 20:15
RE:
Panagiotis Charalampous said:
Hi DelTrader,
Most probably your condition is not fulfilled
if (myPositionsSymbol1.Length <= (MaxOpenTradesSymbol1 - 1) && Symbol1Spread <= MaxSpreadSymbol1) {However we cannot advise further if we don't know what this condition is supposed to do and what do the parameters mean. For example, we don't know what MaxOpenTradesSymbol1 or LabelSymbol1
Best Regards,
Panagiotis
I always apreciate your help Panagiotis!
When i start cBot, he ExecuteBuyStrategySymbol1() without problems.
Here the parameters:
Thank you
[Parameter("Max Open Trades Symbol 1", DefaultValue = 1)] public int MaxOpenTradesSymbol1 { get; set; } [Parameter("Symbol 1", DefaultValue = "EURUSD")] public string Symbol1 { get; set; } private const string LabelSymbol1 = "MaybeIMaybeYou V6.1 - Symbol 1";
@DelFonseca
PanagiotisCharalampous
16 Feb 2018, 09:30
( Updated at: 19 Mar 2025, 08:57 )
Hi DelTrader,
Thanks but probably this is not enough, As I said, it seems that your condition is never fulfilled. In order to understand why the condition is not fullfiled, we will need to know what values do the different variables have at the time when this line of code is reached. So the only way to do this is to actually debug the cBot. This means that we will need the full source code as well as the execution parameters (Symbol, timeframe etc). If you don't want to expose your cBot publicly, you can contact me at support@ctrader.com.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
15 Feb 2018, 10:44
Hi DelTrader,
Most probably your condition is not fulfilled
However we cannot advise further if we don't know what this condition is supposed to do and what do the parameters mean. For example, we don't know what MaxOpenTradesSymbol1 or LabelSymbol1
Best Regards,
Panagiotis
@PanagiotisCharalampous