DailyStopCount is a counter which counts the number of orders in a day which have been stopped.
OnOrderUpdate() captures stop executions and increments a counter.
if(order.Name == "Stop loss" && order.OrderState == OrderState.Filled) { this.DailyStopCount++; }
OnBarUpdate() checks the value of the counter and if it has reached a certain number, then it just exits. Otherwise, it calls EnterLong().
protected override void OnBarUpdate() { if (Bars.IsFirstBarOfSession) { this.DailyStopCount = 0; } if(this.DailyStopCount >= this.DailyStopLimit) return; EnterLong(); }
if (order.Name == "Buy" && order.OrderState == OrderState.Filled) { SetStopLoss(CalculationMode.Ticks, this.StopLoss); SetProfitTarget(CalculationMode.Ticks, this.StopLoss); }
1. There would not be a single trade that losses more than 10 ticks. But there are some. (see PNG attached).
2. There would not be a single day that losses more than 20 ticks. But there are some that lose 40. (see PNG attached).
My questions are:
1. Am I coding this up correctly?
2. Is it possible to make it so that there is not a single trade that losses more than 10 ticks?
3. Is it possible to make it so that there is no day that loses more than 20 ticks?
4. Why does this strategy have some trades which lose more than 10 ticks and some days which loss more than 20 ticks?
I am sure that I just misunderstand the way that NT works, but I just cannot figure out what the problem is.
I understand that in trading there is no guarantee of stops etc... but this is simulation so I did expect that the stops would not be breached by these amounts. The Stop Loss is set to 10 pips in the example but two of the trades lose 19 pips.
Comment