ritracciamento supertrend 2 minuti

Viewing 2 posts - 46 through 47 (of 47 total)
  • Author
    Posts
  • #187824 quote
    emanuele81
    Participant
    Senior

    é possibile introdurre uno stop quando la posizione arriva a guadagnare 30 pip lo stop va alla posizione di partenza, quindi perdita a 0

    #187875 quote
    robertogozzi
    Moderator
    Master

    Ho aggiunto il Trailing Stop di Nicolas (linee 17-56 del codice che puoi trovare a https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/), indicando un passo 0, in modo che metta solo in pareggio dopo 30 pips:

    // SuperTrend
    //
    //https://www.prorealcode.com/topic/ritracciamento-supertrend-2-minuti/page/2/#post-185761
    //
    DEFPARAM CumulateOrders = false
    Defparam Flatbefore     = 010000
    Defparam Flatafter      = 220000
    Timeframe(4h,UpdateOnClose)
    H4close = close[1]
    //
    Timeframe(4h,default)
    ONCE IncrocioST  = 0
    ONCE IncrocioST2 = 0
    ST               = Supertrend[2,20]    //2,20
    ST2              = Supertrend[8,10]    //8,10
    ST2rialzista     = close > ST2
    ST2ribassista    = close < ST2
    IF close CROSSES OVER ST2 OR close CROSSES UNDER ST2 THEN
    IncrocioST2 = close
    ENDIF
    IF close CROSSES OVER ST  OR close CROSSES UNDER ST  THEN
    IncrocioST  = close
    ENDIF
    CondL1 = Not OnMarket
    CondL2 = close > H4close
    CondL3 = IncrocioST < IncrocioST2
    CondL4 = ST2rialzista
    CondL5 = Not OnMarket
    CondL6 = close CROSSES OVER  ST
    CondL  = CondL1 AND CondL2 AND CondL3 AND CondL4 AND CondL5 AND CondL6
    IF CondL THEN
    BUY 1 Contract AT Market
    ENDIF
    //
    CondS1 = CondL1
    CondS2 = close < H4close
    CondS3 = IncrocioST > IncrocioST2
    CondS4 = ST2ribassista
    CondS5 = CondL5
    CondS6 = close CROSSES UNDER ST
    CondS  = CondS1 AND CondS2 AND CondS3 AND CondS4 AND CondS5 AND CondS6
    IF CondS THEN
    SELLSHORT 1 Contract AT Market
    ENDIF
    //
    Timeframe(default)
    //SET STOP   pLOSS   50
    //
    //************************************************************************
    //trailing stop function
    trailingstart = 30    //30  trailing will start @trailinstart points profit
    trailingstep  = 0     //0   trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //************************************************************************
    //graphonprice ST  coloured(255,0,0,255) AS "SuperTrend Veloce"
    //graphonprice ST2 coloured(0,0,255,255) AS "SuperTrend Lento"
    //graphonprice NewSL AS "StopLoss"
    //graph positionprice*positionperf/pipsize AS"Profitto"
    SuperTrend2.itf
Viewing 2 posts - 46 through 47 (of 47 total)
  • You must be logged in to reply to this topic.

ritracciamento supertrend 2 minuti


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
emanuele81 @emanuele81 Participant
Summary

This topic contains 46 replies,
has 4 voices, and was last updated by robertogozzi
4 years ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 01/01/2022
Status: Active
Attachments: 8 files
Logo Logo
Loading...