Tradeindex must be referenced using PARENTHESES, not brackets. The last operation’s bar is TRADEINDEX or TRADEINDEX(1).
Be warned that TRADEINDEX will be aware of the newly opened (or closed) trade at the closing of the candle, so lines 19-21 will only be executed from the second bar on…
Bear in mind that TRADEINDEX is the bar when the last operation (be it Entry or Exit) is executed.
Thanks for the feedback Roberto.
I seem to get the same results. No SL is set up.
I’ve added the following screenshots with results where a trade is triggered and where a stop should be placed:
1. My original code.
2. The adjusted code with your changes.
3. Replacing the code with a simple fixed 20-point SL.
When I replace the code with a simple SET STOP LOSS 20, I get the required entry and exit.
My fault, I didn’t realize that you are setting your Stop Loss at a PRICE level, not a PRICE DIFFERENCE. Replace SET STOP LOSS with SET STOP PRICE as follows:
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