what i am trying to do is print something when there is 3 consecutive losses and print again when there is another 3 new consecutive losses
here is the code i have come up with so far, the problem with this code is that it keeps printing on the forth and 5th losses and so on (see image to better understand my point )
any solutions
protected override void OnPositionUpdate(Cbi.Position position, double averagePrice, int quantity, Cbi.MarketPosition marketPosition) { if ( Position.MarketPosition == MarketPosition.Flat) { if (SystemPerformance.AllTrades.Count > 3) { Trade lastTrade1 = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1]; Trade lastTrade2 = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 2]; Trade lastTrade3 = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 3]; if(lastTrade1.ProfitPercent < 0 && lastTrade2.ProfitPercent < 0 && lastTrade3.ProfitPercent < 0 ) { Print("three consecutive losses") ; } } } }
thanks in advance
Comment