Reverse position and set new stop

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5451 quote
    Henry
    Participant
    Average

    A request that was addressed to ProRealTime:

     

    Reverse the position (Stop&Reverse) if the price reaches the stop loss, with new stop above the high of the previous bar; it’s possible? Thank you

    DEFPARAM FlatBefore=080000
    DEFPARAM FlatAfter=220000
    DEFPARAM CumulateOrders = false
    D = ExponentialAverage[21](close)
    
    ncontratti=50
    MyBorder=(TICKSIZE*1)
    MySpread=(TICKSIZE*2)
    var1=1
    var2=3
    
    filterL1 = Low[1]>D[1] and Low<=D and High>=D
    filterL2 = Low[2]>D[2] and Low[1]<=D[1] and High[1]>=D[1] and High>=D and High<=High[1]+MyBorder
    filterL3 = Low[3]>D[3] and Low[2]<=D[2] and High[2]>=D[2] and High[1]>=D[1] and High>=D and High<=High[1]+MyBorder
    
    sup=high+MySpread
    inf=low-MySpread
    inf2=MIN(low[1],low)-myspread
    inf3=MIN(low[2],low)-myspread
    
    IF filterL1 and NOT ONMARKET THEN
    ampiezza=((sup-inf)/(1*Ticksize))*var1
    ampiezzaP=((sup-inf)/(1*Ticksize))*var2
    BUY ncontratti CONTRACTS AT sup STOP
    ENDIF
    IF filterL2 and NOT ONMARKET THEN
    ampiezza=((sup-inf2)/(1*Ticksize))*var1
    ampiezzaP=((sup-inf2)/(1*Ticksize))*var2
    BUY ncontratti CONTRACTS AT sup STOP
    ENDIF
    IF filterL3 and NOT ONMARKET THEN
    ampiezza=((sup-inf3)/(1*Ticksize))*var1
    ampiezzaP=((sup-inf3)/(1*Ticksize))*var2
    BUY ncontratti CONTRACTS AT sup STOP
    ENDIF
    
    SET STOP pLOSS ampiezza
    SET TARGET pPROFIT ampiezzaP

    Suggestion for an anwser:

    DEFPARAM FlatBefore=080000
    DEFPARAM FlatAfter=220000
    DEFPARAM CumulateOrders = false
    D = ExponentialAverage[21](close)
    
    ncontratti=50
    MyBorder=(TICKSIZE*1)
    MySpread=(TICKSIZE*2)
    var1=1
    var2=3
    
    filterL1 = Low[1]>D[1] and Low<=D and High>=D
    filterL2 = Low[2]>D[2] and Low[1]<=D[1] and High[1]>=D[1] and High>=D and High<=High[1]+MyBorder
    filterL3 = Low[3]>D[3] and Low[2]<=D[2] and High[2]>=D[2] and High[1]>=D[1] and High>=D and High<=High[1]+MyBorder
    
    sup=high+MySpread
    inf=low-MySpread
    inf2=MIN(low[1],low)-myspread
    inf3=MIN(low[2],low)-myspread
    
    IF filterL1 and NOT ONMARKET THEN
    ampiezza=((sup-inf)/(1*Ticksize))*var1
    ampiezzaP=((sup-inf)/(1*Ticksize))*var2
    BUY ncontratti CONTRACTS AT sup STOP
    SET STOP pLOSS ampiezza
    ENDIF
    IF filterL2 and NOT ONMARKET THEN
    ampiezza=((sup-inf2)/(1*Ticksize))*var1
    ampiezzaP=((sup-inf2)/(1*Ticksize))*var2
    BUY ncontratti CONTRACTS AT sup STOP
    SET STOP pLOSS ampiezza
    ENDIF
    IF filterL3 and NOT ONMARKET THEN
    ampiezza=((sup-inf3)/(1*Ticksize))*var1
    ampiezzaP=((sup-inf3)/(1*Ticksize))*var2
    BUY ncontratti CONTRACTS AT sup STOP
    SET STOP pLOSS ampiezza
    ENDIF
    
    IF LONGONMARKET THEN
    SET STOP PLOSS 0
    SELLSHORT ncontratti CONTRACTS AT TRADEPRICE - ampiezza*pointsize STOP
    SHORTSTOP=HIGH[1]+1*POINTSIZE
    EXITSHORT AT SHORTSTOP STOP
    ENDIF
    
    IF SHORTONMARKET THEN
    EXITSHORT AT SHORTSTOP STOP
    ENDIF
    
    SET TARGET pPROFIT ampiezzaP
    #5456 quote
    Flavio
    Participant
    New

    tank you for anwser!

    Flavio

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

Reverse position and set new stop


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Henry @henry Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Flavio
9 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/15/2016
Status: Active
Attachments: No files
Logo Logo
Loading...