aiuto su codici pivot

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #46911 quote
    Raffaele GrossoRaffaele Grosso
    Participant
    Junior

    vorrei creare un codice che

    entra short quando il prezzo incrocia a rialzo pivot resistenza 1 e lo stesso resistenza 2 e 3

    entra long quando il prezzo incrocia a ribasso supporto 1 2 e 3

    stop loss 10 punti (da ottimizzare)

    profit dopo 5 punti

    grazie

    #46921 quote
    NicolasNicolas
    Keymaster
    Legend

    Ho codificato la strategia per te, ti preghiamo di trovarla qui sotto:

    defparam cumulateorders=false
    
    //Pivot calculation method
    Once mode = 1
    
    Once dailyPivot = undefined
    Once dailyR1 = undefined
    Once dailyS1 = undefined
    Once dailyR2 = undefined
    Once dailyS2 = undefined
    Once dailyR3 = undefined
    Once dailyS3 = undefined
    
    If Day>Day[1] then
    If mode = 0 then
    dailyPivot = (DHigh(1) + DLow(1) + Close[1]) / 3
    Elsif mode = 1 then
    dailyPivot = (Open + DHigh(1) + DLow(1) + Close[1]) / 4
    Elsif mode = 2 then
    dailyPivot = (DHigh(1) + DLow(1) + Close[1]*2) / 4
    Else
    dailyPivot = (Open*2 + DHigh(1) + DLow(1)) / 4
    Endif
    dailyR1 = 2*dailyPivot - DLow(1)
    dailyS1 = 2*dailyPivot - DHigh(1)
    dailyR2 = dailyPivot + (DHigh(1) - DLow(1))
    dailyS2 = dailyPivot - (DHigh(1) - DLow(1))
    dailyR3 = dailyR1 + (DHigh(1) - DLow(1))
    dailyS3 = dailyS1 - (DHigh(1) - DLow(1))
    Endif
    
    if close crosses over dailyr1 or close crosses over dailyr2 or close crosses over dailyr3 then 
    buy 1 contract at market 
    endif 
    
    if close crosses under dailys1 or close crosses under dailys2 or close crosses under dailys3 then 
    sellshort 1 contract at market 
    endif  
    
    set target pprofit 5
    set stop ploss 10
    pivot-points-trading-strategy.png pivot-points-trading-strategy.png
    #46926 quote
    Raffaele GrossoRaffaele Grosso
    Participant
    Junior

    grazie mille

    #46935 quote
    Raffaele GrossoRaffaele Grosso
    Participant
    Junior

    ciao Nicolas

    ma dal backtest vedo che il codice non entra quando il prezzo incrocia a rialzo o a ribasso il pivot o non sempre

    #46944 quote
    NicolasNicolas
    Keymaster
    Legend

    Non ero ancora sicuro del livello del perno, ecco il codice modificato di conseguenza:

    defparam cumulateorders=false
    
    //Pivot calculation method
    Once mode = 1
    
    Once dailyPivot = undefined
    Once dailyR1 = undefined
    Once dailyS1 = undefined
    Once dailyR2 = undefined
    Once dailyS2 = undefined
    Once dailyR3 = undefined
    Once dailyS3 = undefined
    
    If Day>Day[1] then
    If mode = 0 then
    dailyPivot = (DHigh(1) + DLow(1) + Close[1]) / 3
    Elsif mode = 1 then
    dailyPivot = (Open + DHigh(1) + DLow(1) + Close[1]) / 4
    Elsif mode = 2 then
    dailyPivot = (DHigh(1) + DLow(1) + Close[1]*2) / 4
    Else
    dailyPivot = (Open*2 + DHigh(1) + DLow(1)) / 4
    Endif
    dailyR1 = 2*dailyPivot - DLow(1)
    dailyS1 = 2*dailyPivot - DHigh(1)
    dailyR2 = dailyPivot + (DHigh(1) - DLow(1))
    dailyS2 = dailyPivot - (DHigh(1) - DLow(1))
    dailyR3 = dailyR1 + (DHigh(1) - DLow(1))
    dailyS3 = dailyS1 - (DHigh(1) - DLow(1))
    Endif
    
    if close crosses over dailyr1 or close crosses over dailyr2 or close crosses over dailyr3 or close crosses over dailypivot then 
    buy 1 contract at market 
    endif 
    
    if close crosses under dailys1 or close crosses under dailys2 or close crosses under dailys3 or close crosses under dailypivot then 
    sellshort 1 contract at market 
    endif  
    
    set target pprofit 5
    set stop ploss 10
    #46970 quote
    Raffaele GrossoRaffaele Grosso
    Participant
    Junior

    ciao Nicolas 

    scusami ma io sono alle prime armi

    non esitite un comando che fa entrate appena il prezzo tocca il pivot e non alla chiusura della barra?

    #47239 quote
    NicolasNicolas
    Keymaster
    Legend

    Dovrebbe essere possibile con questo codice:

    defparam cumulateorders=false
    
    //Pivot calculation method
    Once mode = 1
    
    Once dailyPivot = undefined
    Once dailyR1 = undefined
    Once dailyS1 = undefined
    Once dailyR2 = undefined
    Once dailyS2 = undefined
    Once dailyR3 = undefined
    Once dailyS3 = undefined
    
    If Day>Day[1] then
    If mode = 0 then
    dailyPivot = (DHigh(1) + DLow(1) + Close[1]) / 3
    Elsif mode = 1 then
    dailyPivot = (Open + DHigh(1) + DLow(1) + Close[1]) / 4
    Elsif mode = 2 then
    dailyPivot = (DHigh(1) + DLow(1) + Close[1]*2) / 4
    Else
    dailyPivot = (Open*2 + DHigh(1) + DLow(1)) / 4
    Endif
    dailyR1 = 2*dailyPivot - DLow(1)
    dailyS1 = 2*dailyPivot - DHigh(1)
    dailyR2 = dailyPivot + (DHigh(1) - DLow(1))
    dailyS2 = dailyPivot - (DHigh(1) - DLow(1))
    dailyR3 = dailyR1 + (DHigh(1) - DLow(1))
    dailyS3 = dailyS1 - (DHigh(1) - DLow(1))
    Endif
    
    if close>dailyr3 then 
     sellshort 1 contract at dailyr3 stop
    elsif close<dailyr3 and close>dailyr2 then 
     sellshort 1 contract at dailyr2 stop
     buy 1 contract at dailyr3 stop
    elsif close<dailyr2 and close>dailyr1 then 
     sellshort 1 contract at dailyr1 stop
     buy 1 contract at dailyr2 stop
    elsif close<dailyr1 and close>dailypivot then 
     sellshort 1 contract at dailypivot stop
     buy 1 contract at dailyr1 stop
    elsif close<dailypivot and close>dailys1 then 
     sellshort 1 contract at dailys1 stop
     buy 1 contract at dailypivot stop
    elsif close<dailys1 and close>dailys2 then 
     sellshort 1 contract at dailys2 stop
     buy 1 contract at dailys1 stop
    elsif close<dailys2 and close>dailys3 then 
     sellshort 1 contract at dailys3 stop
     buy 1 contract at dailys2 stop
    elsif close<dailys3 then 
     buy 1 contract at dailys3 stop
    endif
    
    set target pprofit 5
    set stop ploss 10

    Questo codice utilizza ordini in sospeso, è consapevole che per utilizzare questo tipo di ordini, il prezzo effettivo deve essere conforme alle limitazioni del broker per metterle sul mercato (almeno X pips dal prezzo)
    Non l’ho provata, per favore le tue simulazioni e le tue prove e per ricevere feedback….

Viewing 7 posts - 1 through 7 (of 7 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

aiuto su codici pivot


ProOrder: Trading Automatico & Backtesting

New Reply
Author
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by NicolasNicolas
9 years ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 09/22/2017
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...