first of all, I apologize for my English, I hope the question is understandable. I attach my strategy so that my questions are clearer (I put further strategy considerations highlighted with a double comment).
I created a Multi-Time Frame strategy with ninjiascript 8, which uses 1 minute bars as "primary bars" and 1 bar as "secondary bars".
My goal is to use 1 minute bars for analysis and 1 bar for trading. To do this I used a Boolean "control" variable that allows me not to scroll the bars with 1 tick until the strategy is active.
Once the strategy comes into play, the problems begin.
1) When the "control" variable becomes true at the end of minute X of the "primary bars", I have not been able to understand whether the "secondary bars" start from time X or from time X + 1 (as it would be in reality).
2) I tried the strategy on Futures ESM2020 of 29 April 2020, the result of the simulated strategy in Matlab gave me the following results:
- Enter long: 00:12 and 00:13 used as condition to primary bars; 00:14 used as secondary bars for trading.
- Enter to tick in second: 00:14:32 at the exact price of 2869.75 (=Highs[0][0])
- Exit to tick in second: 00:14:43 with stop-loss at 2868.00 (=Lows[0][0])
I should go out with the stop loss instead the exit is this:
DATE-TIME: 29/04/2020 00:12:00
HIGH[1]: 2870,5
LOW[1]: 2869
DATE-TIME: 29/04/2020 00:13:00
HIGH[0]: 2869,75
LOW[0]: 2868
gain_lose_gap: 1,75
enter_level: 2869,75
exit_level: 2868
gain_level: 2871,5
Print pre-order: 29/04/2020 00:13:01
29/04/2020 00:13:01 Strategy 'ProvaLongPosition4/200517373': Entered internal SubmitOrderManaged() method at 29/04/2020 00:13:01: BarsInProgress=1 Action=Buy OrderType=StopLimit Quantity=1 LimitPrice=2869,75 StopPrice=2869,75 SignalName='My_first_strategy' FromEntrySignal=''
Print post-order 29/04/2020 00:13:01
29/04/2020 00:13:32 Strategy 'ProvaLongPosition4/200517373': Entered internal SubmitOrderManaged() method at 29/04/2020 00:13:32: BarsInProgress=1 Action=Sell OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=2868,00 SignalName='exit' FromEntrySignal='My_first_strategy'
29/04/2020 00:13:32 Strategy 'ProvaLongPosition4/200517373': Entered internal SubmitOrderManaged() method at 29/04/2020 00:13:32: BarsInProgress=1 Action=Sell OrderType=Limit Quantity=1 LimitPrice=2871,50 StopPrice=0 SignalName='gain' FromEntrySignal='My_first_strategy'
29/04/2020 00:13:43 Strategy 'ProvaLongPosition4/200517373: Cancelled pending exit order, since associated position is closed, orderId='NT-00002-48' account='Sim101' name='gain' orderState=Working instrument='ES 06-20' orderAction=Sell orderType='Limit' limitPrice=2871.5 stopPrice=0 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-04-29 00:13:32' gtd='2099-12-01' statementDate='2020-05-10'
Comment