3 trading system

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #157256 quote
    GaelGael
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    Cercherò di farteli, magari uno alla volta.

    #157291 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    GaelGael
    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.
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

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 GaelGael
5 years, 8 months ago.

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