Advertisement
pattty847

Untitled

Sep 27th, 2021
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. It's important to understand pinescript:
  2. 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.
  3.  
  4. So, the function is called every time the price changes, but the function only reacts when the close occurs:
  5.  
  6. bindex := close > close[bars_back] ? bindex + 1 : bindex
  7.  
  8. ^^ This is a counter that counts 1 everytime the close is greater than the close [bars_back], which is 4 in default settings.
  9.  
  10. if bindex > bars and close < open and high >= highest(high, len) and flip == 0
  11.  
  12. ^^ 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)
  13.  
  14. bindex := 0
  15.  
  16. ^^ This resets our counter to start over
  17.  
  18. // assign bearish signal
  19. return := -1
  20.  
  21. Sets the return variable to -1 for the bearish signal we need
  22.  
  23. // return it
  24. return
  25.  
  26. ^^ This returns the variable -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement