Maurizio-Ciullo

28 Personale Plottare PiΓΉ Condizioni Buleane Iniseme

May 15th, 2022 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 ----------------   Lezione 28 Personale Plottare PiΓΉ Condizioni Buleane Iniseme    ------------------------//
  2.  
  3. // Il buleano ritorna il valore di 1
  4. // Con buleano true and buleano true avremo 1 true and 1 true
  5. // Con bgcolor plottiamo se entrambe le condizioni contemporeneamente sono vere
  6.  
  7. // upBar = close > open
  8. // threeUpBars = upBar and upBar[1] and upBar[2]
  9.  
  10. // bgcolor(threeUpBars ? color.new(color.green, 80) : na, title="upBar", offset=0)
  11.  
  12.  
  13.                                    //------------   Altro modo per fare la stessa cosa --------------------//
  14.  
  15. // Con la seguente formula: math.sum(upBar ? 1 : 0, 3) == 3
  16. // Sommiano tutti i true e inserendo poi :0,"numero di condizioni per i true" esempio: 0, 3
  17. // con == "numero di condizioni per i true che vogliamo in output", esempio: 3
  18. // otteniamo la stessa verifica
  19.  
  20.  
  21. //which produces a value of 1 every time the upBar boolean variable is true,
  22. //and adds the number of those values for the last 3 bars. When that rolling sum equals 3, threeUpBars is true.
  23.  
  24. upBar = close > open
  25. threeUpBars = upBar and upBar[1] and upBar[2]
  26.  
  27. threeUpBars = math.sum(upBar ? 1 : 0, 3) == 3  
  28.  
  29. bgcolor(threeUpBars ? color.new(color.green, 80) : na, title="threeUpBars", offset=0)
  30.  
  31.                                                  //------------   Altro Esempio --------------------//
  32.  
  33. // Possiamo anche usare gli operatori logici come output
  34.  
  35. upBar = close > open
  36.  
  37. only_seven_Up_bar_of_ten = math.sum(upBar ? 1 : 0,10) >=7
  38. bgcolor(only_seven_Up_bar_of_ten ? color.new(color.green, 80) : na, title="only_seven_Up_bar_of_ten", offset=0)
Add Comment
Please, Sign In to add comment