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
SpartakusLIVE
6 hours agoTiger Blood RESTOCKED and 30% off w/ code SPARTAKUS30
524 watching -
24:58
Law&Crime
6 hours ago $0.56 earnedSecond Note Leaves Disturbing Clues in New York City Killings
15.2K5 -
1:36:57
Badlands Media
22 hours agoAltered State S3 Ep. 39
43.8K10 -
2:04:07
Due Dissidence
11 hours agoCharlie Kirk's GAZA LIES, Caitlin Clark Stalker, Palantir Goes Hollywood - w/ Kyle Matovcik | TMWS
18K5 -
LIVE
I_Came_With_Fire_Podcast
13 hours agoAmerica First, Trump Threatens China, Your Friendly Neighborhood Illegal, EPA Gets a "W"
336 watching -
LIVE
Geeks + Gamers
3 hours agoGeeks+Gamers Play- MARIO KART WORLD
131 watching -
8:28:19
Dr Disrespect
12 hours ago🔴LIVE - DR DISRESPECT - BATTLEFIELD 1 - FULL GAME
161K7 -
1:39:26
Glenn Greenwald
8 hours agoStephen Miller's False Denials About Trump's Campus "Hate Speech" Codes; Sohrab Ahmari on the MAGA Splits Over Antitrust, Foreign Wars, and More | SYSTEM UPDATE #495
105K54 -
1:57:28
Omar Elattar
8 hours agoThe $300M CEO: "The One Skill That Made Me Rich In 15 Different Countries!"
16.8K -
LIVE
xXFadedAngelXx
4 hours ago180 HOURGLASS PULL! Wisdom of Sea and Sky (Pokemon TCG Pocket) Then some RL with Meditayte later
20 watching