Premium Only Content

Tutorial 204 | Looking for conditions to occur within specified numbers of bars of each other
A Gold Pass asked for a tutorial about how to write a program that looked for three conditions to occur, in order. The first condition should occur, then the second condition should occur within a specified number of bars of the first. Finally a third condition would occur within a certain number of bars of the second.
The occurances being looked for in this show me study are a moving average cross over, a doji and and Bullish Harami. There was no particular logic in picking these specific conditions merely just a way of demonstrating this technique.
In this example the program looks for the moving average cross over. When it found it then looks for a Doji for the next 5 bars. If the Doji is found the program then looks for a Bullish Harami with the next 24 bars. The show me plots every time one of the conditions is found, a green dot for the average cross-over, a blue dot for a Doji and a red dot for a Bullish Harami.
In the strategy version a market order is made when the three conditions have occurred.
The way the program works is by using counters that continually increment. When one of the conditions occurs, the counter for that condition is reset to zero.
Note that the initial values for the counters are set to a level where a condition is erroneously recorded.
It is useful to create a show me study prior to a strategy to ensure that the program is working as anticipated.
-
1:33:51
Steve-O's Wild Ride! Podcast
1 day ago $0.92 earnedJohn C. Reilly's Surprising Connection To Jackass (And Beef With Weeman!)
22.9K5 -
LIVE
StoneMountain64
3 hours agoBattlefield 6 News and Extraction Gaming
79 watching -
2:13:30
Side Scrollers Podcast
6 hours agoUK Introduces MANDATORY Digital ID + Dallas ICE Shooting BLAMED on Gaming + More | Side Scrollers
85.8K7 -
1:54:17
The Charlie Kirk Show
4 hours agoCharlie's Last Trip + What's Next + AMA | Erika Kirk, Mikey McCoy | 9.26.2025
272K234 -
1:02:53
The Quartering
3 hours agoMAGA Kid Kidnapped, Hasan Piker Meltdown, Vivek Fights For Alex Jones & More
129K44 -
32:49
Simply Bitcoin
1 day ago $1.83 earnedBitcoin Crucible w/ Alex Stanczyk | EP 1
36.4K -
1:57:37
Tucker Carlson
3 hours agoCharlie Sheen’s Craziest Hollywood Stories and Why He Refuses to Believe the Official Story of 9/11
60.2K59 -
1:33:12
Sean Unpaved
4 hours agoRyder Cup Tee-Off, CFB's Week 5 Madness, & the NFL's Win-or-Wilt Week 4
31.9K1 -
2:07:01
The Culture War with Tim Pool
5 hours agoWho Really Killed Charlie Kirk? Truth Behind Kirk Assassination | The Culture War with Tim Pool
244K232 -
1:25:28
Lara Logan
15 hours agoTHE REMNANT RISES: Matt Shea & The New Generation of Pastors on Fire for God & Country | Episode 37
42.8K4