When a certain condition is met the system must:
Remember the highest high of the previous 3 bars for a possible long position, and
Remember the lowest low of the previous 3 bars for a stoploss of a possible long
I have the same rules (opposite condition) for going short.
I am having a problem with the "advanced order handling"
When the system goes long a setstoploss is placed - which then prevents a short order from being filled. I have therefore decided to only use enterlong, exitlong, entershort and exitshort (these orders do not seem to have the same complications as stop orders)
The thing is I do not want to only place orders when a bar has closed. I want to for example go long whenever the price goes higher than the highest high of the previous 3 bars - and the condition is true.
I have started to look at making calculateonbarclose = false. What I don't understand is what price Close[0] refers to when calculateonbarclose = false. Does it still wait for a bar to close.
The ideal would be if someone can show be a good example of advanced order handling where both long and short positions are taken. The examples I could find show going in one direction only.
Or if someone can give me some kind of "template" to do the following:
If long condition is met and price > highest high of previous 3 bars then go long immediately, and
place stop loss order below lowest low of previous 3 bars
If short condition is met and price < lowest low of previous 3 bars then go short immediately, and
place stop loss order above highest high of previous 3 bars
If system is long and condition for short position is met then exit long and go short. The way it is coded now the long position is only closed by the stoploss - never by a short position. I have read the documentation on advanced order handling but are still stuck
Sorry for being so long

Comment