i have written a strategy but I am having trouble with the code.
I only want to take a entry after my conditions have been met on the current candle and not carry forward to the next candle.
So buy stop at the high of the previous candle high and if it does not enter on the current candle then to cancel the order even if the conditions are still met on the next candle.
Strategies are ALWAYS executed when a bar closes, just microseconds before the next one opens, so your current bars is the bar just closed and can ve referred by [0] or no brackets at all. To place a pending BUY order on the previous HIGH (that is the HIGH of the candle preceding the one just closed) you just have to write:
1
BUY1CONTRACTATHigh[1]STOP//or LIMIT if current price is higher than high[1]
Pending orders are always CANCELLED when each bar closes, if not triggered. So you just need not to place them again even if conditions are still met next bar.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue