Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 18:43:59 +0000



Post From: Open trade at next candle open

[2024-02-18 21:28:05]
emmanuel - Posts: 58
To do that you need to know two things:

1. The index of the "next" candle.
2. The index of the current candle.

The index of the current candle is:
sc.Index
Naturally, the index of the next candle is:
sc.Index + 1

However, you need to store/remember the index of the next candle before the next candle opens. That's because if you wait until the next candle, then sc.Index would be the next candle and sc.Index + 1 would be the following candle. In other words, the moment in time during which you determine the "next" candle, matters. I hope that makes sense.

Here's how to approach this:

1. Create an integer persistent variable, and initialize it to a value that's not a valid index, such as -1.
2. When the conditions to enter on the next candle open are satisfied, set the persistent variable to sc.Index + 1.
3. Use an if-then block to check if sc.Index is equal to the persistent variable. If so then the next candle has formed; Open the trade and reset the persistent variable to -1.

See Persistent Variable Functions