Our Strategy demonstrates how to calculate all the pivot series using data compressed in the Daily scale and then save the information in the Intraday scale so that it can be charted. Always when working with compressed series, you should be aware of your selected Synchronization Options. For more information, see WealthScript Programming Guide, DataSeries > Accessing Secondary Symbols > Secondary Series Synchronization, and Intraday / Multi-Time Frame | Compressed price series alignment.
The breakout criteria is calculated by multiplying the specified number of ticks by the Tick Value, which is retrieved by the Bars.SymbolInfo.Tick function. The resulting value, boVal, is added to the the first resistance level to go long, or subtracted from the first resistance level to go short. In this demonstration, we use the next resistance level (R2) for a long profit target and the first support level as a stop loss; vice versa for a short position.
We placed additional conditions to not trade on the first 2 bars of the day, nor enter a new trade based on a the last bar. Also note that the BuyAtStop entry signal is processed prior to the ShortAtStop. This gives a slight bias to long entries during backtesting (only), but only if both trades would have triggered on the same bar. In live trading, both Alerts would be generated, so the first to be marketable would be the one that executed.
Finally, notice that we calculate the starting bar of the second day so that we begin the trading loop with valid pivot data from the previous day.