3 trading system

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #157256 quote
    Gael
    Participant
    Average

    Salve a tutti, avrei un favore da chiedervi.

    Postreste per favore tradurre queste tre idee di Trading System (Allegato) in codice per favore.

    Sono a disposizione se non si capisce qualcosa dell’idea.

    Vi ringrazio in anticipo.

    Buona giornata

    TS123.pdf
    #157261 quote
    robertogozzi
    Moderator
    Master

    Cercherò di farteli, magari uno alla volta.

    #157291 quote
    robertogozzi
    Moderator
    Master

    Ecco il primo:

    // Trading System 1
    //
    // https://www.prorealcode.com/topic/3-trading-system/
    //
    DEFPARAM CumulateOrders = FALSE
    // definzizione candele Heikin-Ashi
    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
    xOpen   = (xOpen + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    Bullish    = xClose > xOpen
    Bearish    = xClose < xOpen
    UpperWick  = xHigh - max(xOpen,xClose)
    LowerWick  = min(xOpen,xClose) - xLow
    //
    MySAR = SAR[0.02,0.02,0.2]
    //
    // Entrata LONG
    IF Bullish AND (xClose CROSSES OVER  MySAR) AND (LowerWick = 0) AND Not OnMarket THEN
    BUY 1 Contract at Market
    MyTS = (abs(MySAR - xOpen) / 2) / PipSize
    ENDIF
    // Entrata SHORT
    IF Bearish AND (xClose CROSSES UNDER MySAR) AND (UpperWick = 0) AND Not OnMarket  THEN
    SELLSHORT 1 Contract at Market
    MyTS = (abs(MySAR - xOpen) / 2) / PipSize
    ENDIF
    //
    // Uscita da LONG
    IF LongOnMarket AND Bearish THEN
    SELL at Market
    ENDIF
    // Uscita da SHORT
    IF ShortOnMarket AND Bullish THEN
    EXITSHORT at Market
    ENDIF
    //
    //*********************************************************************************
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (lines 17- 56)
    //
    // Nicolas' trailing stop function
    trailingstart = MyTS    //trailing will start @trailinstart points profit
    trailingstep  = MyTS    //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
    //*********************************************************************************
    Trading-System-1.itf
    #157342 quote
    robertogozzi
    Moderator
    Master

    Non so se avevi già letto il post sopra (Trading System 1), ma ti avviso che l’ho cambiato leggermente ed ho allegato il file ITF.

    #157348 quote
    robertogozzi
    Moderator
    Master

    Ecco il secondo:

    // Trading System 2
    //
    // https://www.prorealcode.com/topic/3-trading-system/
    //
    DEFPARAM CumulateOrders = FALSE
    ONCE N = 3                                       //3 numero candele
    // definzizione candele Heikin-Ashi
    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
    xOpen   = (xOpen + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    Bullish    = xClose > xOpen
    Bearish    = xClose < xOpen
    UpperWick  = xHigh - max(xOpen,xClose)
    LowerWick  = min(xOpen,xClose) - xLow
    //
    MySAR = SAR[0.02,0.02,0.2]
    //
    // Entrata LONG
    IF Bullish AND (xClose CROSSES OVER  MySAR) AND (LowerWick = 0) AND Not OnMarket THEN
    BUY 1 Contract at Market
    MyTS = (abs(MySAR - xOpen) / 2) / PipSize
    ENDIF
    // Entrata SHORT
    IF Bearish AND (xClose CROSSES UNDER MySAR) AND (UpperWick = 0) AND Not OnMarket THEN
    SELLSHORT 1 Contract at Market
    MyTS = (abs(MySAR - xOpen) / 2) / PipSize
    ENDIF
    //
    // Uscita da LONG
    IF LongOnMarket AND (BarIndex - TradeIndex) = (N - 1) THEN
    SELL at Market
    ENDIF
    // Uscita da SHORT
    IF ShortOnMarket AND (BarIndex - TradeIndex) = (N - 1) THEN
    EXITSHORT at Market
    ENDIF
    //
    //*********************************************************************************
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (lines 17- 56)
    //
    // Nicolas' trailing stop function
    trailingstart = MyTS    //trailing will start @trailinstart points profit
    trailingstep  = MyTS    //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
    //*********************************************************************************
    Trading-System-2-1.itf
    #157362 quote
    robertogozzi
    Moderator
    Master

    Terzo ed ultimo:

    // Trading System 3
    //
    // https://www.prorealcode.com/topic/3-trading-system/
    //
    DEFPARAM CumulateOrders = FALSE
    // definzizione candele Heikin-Ashi
    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
    xOpen   = (xOpen + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    Bullish    = xClose > xOpen
    Bearish    = xClose < xOpen
    UpperWick  = xHigh - max(xOpen,xClose)
    LowerWick  = min(xOpen,xClose) - xLow
    // ParabolicSAR
    MySAR   = SAR[0.02,0.02,0.2]
    // Donchian Channel
    ONCE p = 40          //periodi per il canale Donchian
    hh     = highest[p](high)
    ll     = lowest[p](low)
    UPsar  = MySAR => hh
    DNsar  = MySAR <= ll
    //
    // Entrata LONG
    IF Bullish AND (xClose CROSSES OVER  MySAR) AND (LowerWick = 0) AND DNsar AND Not OnMarket THEN
    BUY 1 Contract at Market
    MyTS = (abs(MySAR - xOpen) / 2) / PipSize
    ENDIF
    // Entrata SHORT
    IF Bearish AND (xClose CROSSES UNDER MySAR) AND (UpperWick = 0) AND UPsar AND Not OnMarket THEN
    SELLSHORT 1 Contract at Market
    MyTS = (abs(MySAR - xOpen) / 2) / PipSize
    ENDIF
    //
    // Uscita da LONG
    IF LongOnMarket  AND xHigh >= HH THEN
    SELL at Market
    ENDIF
    // Uscita da SHORT
    IF ShortOnMarket AND xLow  <= LL THEN
    EXITSHORT at Market
    ENDIF
    //
    //*********************************************************************************
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (lines 17- 56)
    //
    // Nicolas' trailing stop function
    trailingstart = MyTS    //trailing will start @trailinstart points profit
    trailingstep  = MyTS    //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
    //*********************************************************************************
    Trading-System-3.itf
    #157380 quote
    Gael
    Participant
    Average

    Grazie mille Roberto, davvero troppo gentile.

    Scusa ancora i disturbo, ma ho solo un problema ad aprire i file (.itf), comunque grazie ancora.

    Buona serata

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

3 trading system


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Gael @gael Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by Gael
5 years, 1 month ago.

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