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.
-
LIVE
Game On!
15 hours agoThe GREATEST Monday Night Football Game OF ALL TIME!
1,542 watching -
18:02
Demons Row
21 hours ago $2.74 earnedI Rode Into the Most Feared Motorcycle Club in America 💀🔥
8.59K4 -
2:43
Blackstone Griddles
1 day agoWalking Tacos on the Blackstone Griddle
2.93K2 -
LIVE
BEK TV
23 hours agoTrent Loos in the Morning - 10/07/2025
205 watching -
LIVE
The Bubba Army
22 hours agoChicago Civil WAR? - Bubba the Love Sponge® Show | 10/07/25
1,865 watching -
4:33
The Official Steve Harvey
14 hours ago $1.96 earnedEvery time you thought it was over… it wasn’t...
13.2K1 -
3:07
NAG Daily
16 hours agoYour Inner Dialogue w/ GreenMan
9.57K1 -
3:26
From Zero → Viral with AI
4 days ago $1.14 earnedAI Isn’t the Strategy — It’s the Tool | How AI Can Transform Political Campaigns
8.06K2 -
8:09
DropItLikeItsScott
15 hours ago $0.88 earnedHi Point HP-15 AR Pistol / Accuracy Test
8.29K1 -
52:59
CharLee Simons presents DO NOT TALK
5 days agoWTH is a BAD BUNNY?! Sam Anthony vs. Leftist Lunacy
8.8K11