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
Major League Fishing
8 days agoLIVE! - Fishing Clash Team Series: Summit Cup - Day 6
194 watching -
30:49
MetatronHistory
16 hours agoThe Truth about Women Warriors Based on Facts, Evidence and Sources
5K3 -
15:17
IsaacButterfield
6 hours ago $0.22 earnedAustralia’s Most Hated Politician
4.62K2 -
4:28
MudandMunitions
12 hours agoSHOT Show 2026 Is Locked In and I’m a Gundie Nominee!
3.27K -
1:19:44
Chad Prather
19 hours agoWhen God Shakes the Room: Bold Faith in a Fearful World
62.4K42 -
LIVE
LFA TV
13 hours agoLIVE & BREAKING NEWS! | FRIDAY 11/21/25
2,767 watching -
58:40
Julie Green Ministries
4 hours agoLIVE WITH JULIE
85.1K136 -
1:01:10
Crypto Power Hour
12 hours ago $2.34 earnedAnimus Bitcoin Technology
29.2K8 -
2:22:18
Game On!
19 hours ago $2.87 earnedAnother FOOTBALL FRIDAY! Weekend Preview And BEST BETS!
24.6K1 -
31:55
ZeeeMedia
20 hours agoHow Gold & Silver Fight Against Digital ID ft. Bill Armour | Daily Pulse Ep 148
23.3K9