Seclast and colour choices on engulfing pattern script

Viewed 25

Why was seclast code used in this script?

Why was this coded instead of the names of the colours - #F70317 , #008600

Here is the script would the added alerts I wrote work?

Script below

//@version=2
study("Bullish and Bearish Engulfing")

checkingHighsAndLows(position) =>
    high >= high[position] and low <= low[position]

isBearishEngulfing(position) =>
    checkingHighsAndLows(position) and open >= close[position] and open >= open[position] and close <= open[position] and close <= close[position]

isBullishEngulfing(position) =>
    checkingHighsAndLows(position) and open <= close[position] and open <= open[position] and close >= open[position] and close >= close[position]

secLast = 1

barcolor(isBearishEngulfing(secLast)? #F70317: na)
barcolor(isBullishEngulfing(secLast)? #008600: na)

alertcondition(isBearishEngulfing(secLast), title='E Bear', message='E Bear')
alertcondition(isBullishEngulfing(secLast), title='E Bull', message='E Bull')
1 Answers

It looks like secLast is there if you want to compare the current candle with n candles back. In a sense that if it engulfs the candle that was formed n bars ago.

Not all colors are built-in variables. So, you can refer to any specific color with the hex representation like #F70317 or you can use the color.rgb() in new versions of pinescript.

Your alert fucntions should work.

Related