Aggiungere un ordine STOP ad una strategia

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #15575 quote
    RafaelNRafaelN
    Moderator
    Senior

    Qui di seguito una domanda inviata a ProRealTime :

    Vorrei aggiungere un trailing stop a questa strategia?
    Cordialmente,

     
    REM// Parametri indicatori
    x=ExponentialAverage[13](close)
    y=ExponentialAverage[17](close)
    w=WeightedAverage[48](close)
    z=SmoothedStochastic[17,8](close)
     
    // Condizioni per entrare su posizioni long
    indicator1 = x
    indicator2 = y
    c1 = (indicator1 CROSSES OVER indicator2[1])
     
    indicator3 = z
    c2 = (indicator3 <= 51)
     
    indicator4 = Adx[11]
    c3 = (indicator4 >= 26)
     
    indicator17 = close
    indicator9 = w
    c4 = (indicator17 > indicator9[1])
     
    indicator20 = z
    indicator15 = WeightedAverage[20](z)
    c11 = (indicator20 > indicator15[1])
     
    IF time >090000 and time <200000 and c1 AND c2 AND c3 AND c4 and c11 THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP PLOSS 56
    ENDIF
     
    // Condizioni per uscire da posizioni long
    indicator11 = x
    indicator12 = y
    c5 = (indicator11 CROSSES UNDER indicator12)
     
    IF c5 THEN
    SELL  AT MARKET
    ELSE
    SET TARGET PPROFIT 118
    ENDIF
     
    // Condizioni per entrare su posizioni short
    indicator5 = x
    indicator6 = y
    c6 = (indicator5 CROSSES UNDER indicator6[1])
     
    indicator7 = z
    c7 = (indicator7 >= 51)
     
    indicator8 = Adx[11]
    c8 = (indicator8 >= 26)
     
    indicator18 = close
    indicator10 = w
    c9 = (indicator18 < indicator10[1])
     
    indicator19 = z
    indicator16 = WeightedAverage[20](z)
    c12 = (indicator19 < indicator16[1])
     
    IF time >090000 and time <200000 and c6 AND c7 AND c8 AND c9 and c12 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    SET STOP PLOSS 56
    ENDIF
     
    // Condizioni per uscire da posizioni short
    indicator13 = x
    indicator14 = y
    c10 = (indicator13 CROSSES OVER indicator14)
     
    IF c10 THEN
    EXITSHORT  AT MARKET
    ELSE
    SET TARGET PPROFIT 132
    ENDIF

     

    E un esempio di risposta :

    Alla strategia è stato aggiunto un working order che segue le funzioni:

    sell at price stop
    exitshort at price stop.

    REM// Parametri indicatori
    x=ExponentialAverage[13](close)
    y=ExponentialAverage[17](close)
    w=WeightedAverage[48](close)
    z=SmoothedStochastic[17,8](close)
    
    // Condizioni per entrare su posizioni long
    c1 = (x CROSSES OVER y[1])
    c2 = (z <= 51)
    
    indicator1 = Adx[11]
    
    c3 = (indicator1 >= 26)
    c4 = (close > w[1])
    
    indicator2 = WeightedAverage[20](z)
    
    c11 = (z > indicator2[1])
    
    IF time >090000 and time <200000 and c1 AND c2 AND c3 AND c4 and c11 THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP PLOSS 56
    long=0
    ENDIF
    if longonmarket then
    if long=0 and close > close[1] then
    long=1
    mylongstop=low-2*pointsize
    endif
    if long=1 then
    if close > close[1] then
    mylongstop=low-2*pointsize
    endif
    sell at mylongstop stop
    endif
    endif
    
    // Condizioni per uscire da posizioni long
    c5 = (x CROSSES UNDER y)
    
    IF c5 THEN
    SELL  AT MARKET
    ELSE
    SET TARGET PPROFIT 118
    ENDIF
    
    // Condizioni per entrare su posizioni short
    c6 = (x CROSSES UNDER y[1])
    c7 = (z >= 51)
    
    c8 = (indicator1 >= 26)
    c9 = (close < w[1])
    
    c12 = (z < indicator2[1])
    
    IF time >090000 and time <200000 and c6 AND c7 AND c8 AND c9 and c12 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    SET STOP PLOSS 56
    short=0
    ENDIF
    if shortonmarket then
    if short=0 and close < close[1] then
    short=1
    myshortstop=high+2*pointsize
    endif
    if short=1 then
    if close < close[1] then
    myshortstop=high+2*pointsize
    endif
    exitshort at myshortstop stop
    endif
    endif
    
    // Condizioni per uscire da posizioni short
    c10 = (x CROSSES OVER y)
    
    IF c10 THEN
    EXITSHORT  AT MARKET
    ELSE
    SET TARGET PPROFIT 132
    ENDIF
    
Viewing 1 post (of 1 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

Aggiungere un ordine STOP ad una strategia


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
RafaelN @rafaeln Moderator
Summary

This topic contains 1 voice and has 0 replies.

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