Advertisement
Maurizio-Ciullo

32 Lezione Personale Plottare In Local Scope

Aug 18th, 2022
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. --------------------------------------------*(32 Lezione Personale Plottare In Local Scope)*-------------------------------------------------
  4.  
  5.  
  6. In questo caso vorrei plottare gli high ed i low giornalieri così anche quando scendo su timeframe minori sono visibili.
  7. Il plot lo voglio visualizzare solo quando in input ho on_off_reverse_cross_activate == true
  8. Per fare questo dovrei fare in questo modo:
  9.  
  10. ////////////////////////                ////////////////////////            ////////////////////////
  11. //Input
  12. on_off_reverse_cross_activate = input.bool(title='Reverse Cross Activate', defval=true, inline='1', group='Test Selection', tooltip="Testa Trend/Reversal/Cross")
  13.  
  14.  
  15. if on_off_reverse_cross_activate == true
  16.     if ta.crossover(close, daily_previous_low)
  17.     plot(daily_previous_low )  *** ERRORE NO POSSO PLOTTARE PERCHE' SONO IN LOCAL SCOPE ***
  18.  
  19. ////////////////////////                ////////////////////////            ////////////////////////
  20.  
  21. Per poter eseguire il plot allora devo usare un ciclo ternario sul plot come segue sotto:
  22.  
  23. ////////////////////////                ////////////////////////            ////////////////////////
  24.  
  25. // Blocco low e high giorno precendete //
  26. daily_previous_low = request.security(syminfo.tickerid, 'D', low[1])
  27. daily_previous_high = request.security(syminfo.tickerid, 'D', high[1])
  28. plot(on_off_reverse_cross_activate ? daily_previous_high : na, color=color.red, style=plot.style_line, linewidth=2, title="daily_previous_high")
  29. plot(on_off_reverse_cross_activate ? daily_previous_low : na, color=color.blue, style=plot.style_line, linewidth=2, title="daily_previous_low")
  30.  
  31.    
  32.  
  33. // Long Short Reverse Cross
  34. if on_off_reverse_cross_activate == true
  35.    if ta.crossover(close, daily_previous_low)
  36.        strategy.entry('operazioneLong', strategy.long, alert_message = "Open Long Position")
  37.    if ta.crossunder(close, daily_previous_high)
  38.        strategy.entry('operazioneShort', strategy.short, alert_message = "Open Short Position")
  39.  
  40.  
  41.                                                            ***  SEGUE  SOLUZIONE  **
  42.  
  43. plot(on_off_reverse_cross_activate ? daily_previous_low : na, color=color.blue, style=plot.style_line, linewidth=2, title="daily_previous_low")
  44. plot(on_off_reverse_cross_activate ? daily_previous_high : na, color=color.red, style=plot.style_line, linewidth=2, title="daily_previous_high")
  45.  
  46. ////////////////////////                ////////////////////////            ////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement