Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- It's important to understand pinescript:
- A Pine script is not like many normal programs that execute once and then stop. In the Pine runtime environment, a script runs in the equivalent of an invisible loop where it is executed once on each historical bar. When execution reaches the last, real-time bar, the script executes once every time a price or volume change is detected, then one final time when the real-time bar closes and becomes a historical bar.
- So, the function is called every time the price changes, but the function only reacts when the close occurs:
- bindex := close > close[bars_back] ? bindex + 1 : bindex
- ^^ This is a counter that counts 1 everytime the close is greater than the close [bars_back], which is 4 in default settings.
- if bindex > bars and close < open and high >= highest(high, len) and flip == 0
- ^^ This is a condition where the counter is greater than a certain number (bars) AND its a red candle (bearish) AND the high of the bar is the highest high over a certain length (len)
- bindex := 0
- ^^ This resets our counter to start over
- // assign bearish signal
- return := -1
- Sets the return variable to -1 for the bearish signal we need
- // return it
- return
- ^^ This returns the variable -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement