info Backtest Supertrend

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #202617 quote
    xcirolix85xcirolix85
    Participant
    New

    Ciao ragazzi, premetto che non sono molto pratico con le programmazioni perchè il mio stile è discrezionale.

    Detto ciò vorrei chiedere se qualche buon anima mi può dare una mano a modificare la scrittura della strategia supertrend di default per fare dei backtest

    Quello che vorrei è:

    • Sul settimanale se il Supertrend è verde cerca solo posizioni LONG
    • Sul settimanale se il Supertrend è rosso cerca solo posizioni SHORT

    TF OPERATIVO

    • Giornaliero: Entra long quando c’è il cambio da rosso a verde / esci quando diventa rosso
    • Giornaliero: Entra short quando c’è il cambio da verde a rosso / esci quando diventa verde
    #202661 quote
    NicolasNicolas
    Keymaster
    Legend

    Ecco il codice che stai cercando. Prendiamo ordini su intervalli di tempo giornalieri Supertend che cambiano colore e con un filtro Supertrend dello stesso colore su base settimanale.

    timeframe(weekly, updateonclose)
    wst = Supertrend[3,10]
    wlong = close>wst
    wshort = close<wst
    
    timeframe(daily,updateonclose)
    dst = Supertrend[3,10]
    if not longonmarket and close crosses over dst and wlong then 
    buy 1 contract at market 
    endif 
    
    if not shortonmarket and close crosses under dst and wshort then 
    sellshort 1 contract at market 
    endif 
    
    
    #202676 quote
    xcirolix85xcirolix85
    Participant
    New

    Grazie della risposta intanto..

    L’ho appena provato ma noto che nel tf operativo, cioè il giornaliero, non chiude le operazioni quando c’è il cambio colore..

    #202681 quote
    NicolasNicolas
    Keymaster
    Legend

    Sì, penso che sia correlato al modo in cui apro l'ordine solo in base al filtro settimanale. Nella versione modificata di seguito, gli ordini vengono chiusi solo in base al cambio colore giornaliero Supertrend, anche se una nuova condizione di ordine contrarian non è ancora soddisfatta:

    timeframe(weekly, updateonclose)
    wst = Supertrend[3,10]
    wlong = close>wst
    wshort = close<wst
    
    timeframe(daily,updateonclose)
    dst = Supertrend[3,10]
    
    if longonmarket and close crosses under dst then 
     sell at market 
    endif 
    if shortonmarket and close crosses over dst then 
     exitshort at market 
    endif 
    
    if not longonmarket and close crosses over dst and wlong then 
    buy 1 contract at market 
    endif 
    
    if not shortonmarket and close crosses under dst and wshort then 
    sellshort 1 contract at market 
    endif
    #202699 quote
    xcirolix85xcirolix85
    Participant
    New

    Ottimo così va benissimo.. grazie mille

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

info Backtest Supertrend


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
xcirolix85 @xcirolix85 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by xcirolix85xcirolix85
3 years, 11 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/16/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...