Coding Project 1

Putting a lot of what we’ve learned so far into practice, we’ll now code a strategy that buys on the popular bullish engulfing candlestick pattern.

Coding Project 1

Step:1 Define Quantifiable Rules

The first step is to define the pattern. Looking closer at the image above, we see that a bullish engulfing could be defined with a few conditions. 

  1. The first candle is negative
  2. The second candle opens with a negative gap
  3. The second candle closes above the open of the previous candle.

Step 2: Translate the rules into Easylanguage

Now we translate the above three rules into Easylanguage.

  1. Close[1]<open[1]
  2. Open<close[1]
  3. Close>open[1]

Step 3: Put it into an if-statement

Now we have the conditions and only need to put them into an if-statement, like below, coupled with an exit of your choice:

If Close[1]<Open[1] and Open<Close[1] and Close>Open[1] then buy next bar open;

If barssinceentry=5 then sell next bar open;

In the exercise section below, you will find more candlesticks to practice on.

>

Login to Your Account



Signup Here
Lost Password