- The strategy is active long term, traded via a VPS and may hold a position for months
- Checks if market position is flat and then submits a buy order when certain conditions are met + a stop loss order at the same time
- Checks if market position is long and then closes position if certain conditions are met
- Order quantity is calculated by an int TradeSize()
What I want to achieve / What the problem is
- I need to be able to deactivate a running strategy (for e.g. server updates/restarts etc) and to reactivate it
- Running strategy particularly means the strategy has one open long position and one stopp loss order (when strategy is flat syncing seems not to be a problem)
- I need the strategy to commence from where it stopped, which means:
b) It must close an open position when the conditions as specified are met going forward
c) It must not open new additional long positions until the strategy is flat again
What I tried
- I was researching the internet, the NT8 guide and especially this forum for days and I still can't make it work:
- I tried to reactive the strategy with "Wait until flat": Strategy turns yellow, sync tab shows "False" and the pending stopp loss gets cancelled
- I tried to reactive the strategy with "Wait until flat (sync account)": Strategy turns yellow, sync tab shows "True", open position gets closed and my stopp gets cancelled
- I tried to reactive the strategy with "Immediately submit": Sometimes it seems to work (while columns: "avg. price" and "unrealised show" different values on the strategy and the positions tab and the stopp loss sometimes has a different value), sometimes also strange things happen: stopp loss remains, strategy turns green but account position is not recognised (=0) even though a position exists and sync tab says "False". Obviously NT can’t allocate the account position to the strategy
- I tried to reactive the strategy with "Immediately submit (sync account)": Shows same result as "Immediately submit"
- I tried to reactive the strategy with "AdoptAccountPosition": Strategy turns green, sync tab shows "False", open position is recognised but strategy position is not recognised (=0) even though it should be long, stopp loss gets cancelled. There are also occasions where it syncs just fine but the stopp is gone.
Conclusion
I believe that "wait until flat“ will not bring me anywhere, so I do concentrate on "Immediately submit" and "AdoptAccountPosition" methods, however I believe I need to adjust the code in order to make things work properly. This is particularly difficult for the "AdoptAccountPosition" option, as the help guide says "Only set to true if you have specifically programmed your strategy to be able to adopt account positions.", but I couldn’t find any documentation how to do that. I would greatly appreciate your help with solving this issue!
Comment