I'm currently developing a trading strategy. I have no previous history in programming, so that's all pretty new to me.It actually worked all just the way it was supposed to (opening/closing trades), but now i tried to add the possibility (with a trade counter, one for short, one for long), to tell the strategy how many trades per direction (long/short) it's supposed to take, before not executing any more trades. But it doesn't take any trades at all now.
I have it set to: CalculateOnBarClose = false;so once it gets the trade signal, it executes the trade. Once the target(s) gets filled it often opens a new one because the trade signal is still there. So sometimes I have 2 trades within one bar. That's OK, but now I'd like to be able to tell the program only to trade for example 3 times and then just to ignore the trade signal.
Once the trade signal (the trade conditions) are not true anymore, it should reset the trade counter immediately, so in case an other signal comes, it will open a new position again (even if it's in the same direction as the trades were before.)
I work with 3 targets (sometime all the same, sometimes different). So those 3 trades for the 3 targets should count as ONE trade taken, not 3.
Below i have a copy of the ninjascript, the way i tried to write it:
Comment