T32b2 = T3(Closes[2], 8, 3, 0.7);
so I set up
BarsRequiredToTrade = 9
as well as
protected override void OnBarUpdate()
{
if (CurrentBars[0] < BarsRequiredToTrade
|| CurrentBars[2] < BarsRequiredToTrade)
return;
but the strategy triggers at the first condition after enabling and sometimes it works, but many times I get the error: " Error on calling 'EventHandlerBarsUpdate' method: Object reference not set to an instance of an object." in the output window, the strategy stops and the Log also shows: "Indicator EMA: Error on calling OnBarUpdate method on bar xxxx: You are trying to access an index with a value that is invalid since it is out of range. I E accessing a series [barsAgo] with an value of 5, when there are only 4 bars on the chart"
Please see the output prints:
Enabling NinjaScript strategy 'ATM2/178977585' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=True CancelExitsOnStrategyDisable=True Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes
Strategy start bar: 5130 - 12/11/2019 15:39:00
++++++++++
Long condition at: 57.46 - Current Ask: 57.46 - S = 1 - Open: 57.44 - Current Bar: 5131 @ 12/11/2019 15:40:00
'GetAtmStrategyEntryOrderStatus' method error: Order ID 'fbd7b92182f649d6a3eba9406bcf9cf5' does not exist
'GetAtmStrategyEntryOrderStatus' method error: Order ID 'fbd7b92182f649d6a3eba9406bcf9cf5' does not exist
'GetAtmStrategyEntryOrderStatus' method error: Order ID 'fbd7b92182f649d6a3eba9406bcf9cf5' does not exist
'GetAtmStrategyEntryOrderStatus' method error: Order ID 'fbd7b92182f649d6a3eba9406bcf9cf5' does not exist
'GetAtmStrategyEntryOrderStatus' method error: Order ID 'fbd7b92182f649d6a3eba9406bcf9cf5' does not exist
'GetAtmStrategyEntryOrderStatus' method error: Order ID 'fbd7b92182f649d6a3eba9406bcf9cf5' does not exist
'GetAtmStrategyEntryOrderStatus' method error: Order ID 'fbd7b92182f649d6a3eba9406bcf9cf5' does not exist
Long ATM triggered at: 57.45 - Open: 57.44 - Current Bar: 5131 - Long order bar: 5131 - 12/11/2019 15:40:00
Comment