So I am trying to code my first strategy in Ninjascript. I have some coding experience, mainly from Java and MQL4 (MT4).
What I want to do is to create a strategy that cancels a limit order I have manually placed, if price comes within a certain distance of the order, and then reverses a specific distance. Basically remove the pending limit order if price comes close, but doesnt trigger, and then retraces.
I have a thought of how I would do this. Get the time of order submission. Get the number of bars since this timestamp, cycle through these bars to find the highest point (if a sell limit). If the highest point is closer than x amount of ticks from my order, and price after that reverses z amount of ticks, cancel the order.
I have a couple of problems tho, the main one (currently), being:
How to cycle through the orders of the current chart symbol? I have been googling and have found one example, creating a for-loop
"for (int j=0; j < NinjaTrader.Cbi.Globals.Accounts[i].Positions.Count; j++ )". But this returns the error "the type or namespace name 'Globals' does not exist in the namespace'NinjaTrader.Cbi'.
Any tips on how to resolve this?
Thank you
Mattias
Comment