Trading system 1.1 point & figure

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

    Avrei un immenso favore da chiedervi, ovvero di tradurre queste idee in codice. Sto usando molto la piattaforma prorealtime, ma faccio ancora fatica a trascrivere le strategie in codice, spero possiate comprendermi.

    Vi lascio in allegato il pdf con le idee di trading System.

    Grazie in anticipo.

    Trading-system-1.1.pdf
    #171239 quote
    robertogozzi
    Moderator
    Master

    Piano piano si possono fare, in parte.

    Renko è possibile, ma i mattoncini non sono quelli di ProrealTime, in quanto per le strategie si possono usare solo TF a tempo; qjuindi vanno adattati al tempo e non sono sempre identici, perchè tra una candela e l’altra non ci possono essere gli stessi Pips. Se vuoi avere un’dea di come sono costruiti e di strategie basta che cerchi RENKO sul forum utilizzando l’apposita casella di ricerca che si apre quando passi sopra il tuo avatar sulla barra blù in alto a destra. Inoltre, siccome ogni volta partono da barre iniziali diverse, i risultati dei backtest non sranno mai uguali.

    Point & Figure non credo si possano simulare, non l’ho mai fatto.

    Nei prossimi giorni ti farò sapere.

    #171329 quote
    robertogozzi
    Moderator
    Master

    Quale indicatore di frattali usi?

    #171362 quote
    Gael
    Participant
    Average

    innanzitutto grazie per la riposta Roberto, poi scusami per la mia ignoranza ma cosa intendi con “quale indicatore di frattali”?

    #171363 quote
    robertogozzi
    Moderator
    Master

    Ci sono vari indicatori di frattali. Comunque userò quello che mi sembra migliore.

    #171382 quote
    robertogozzi
    Moderator
    Master

    FRATTALI
    ————

    L’ho provato sul DAX (Daily, 1h, 30min TF’s); per il trailing stop ho usato il codice di Nicolas:

    // Frattali
    //
    // https://www.prorealcode.com/topic/trading-system-1-1/
    //
    // basato sull'ndicatore:
    //
    //     https://www.prorealcode.com/prorealtime-indicators/bill-williams-fractals/)
    //
    DEFPARAM CumulateOrders = False
    //
    cp = 2           //2  (default)
    LH = 0
    LL = 0
    if high[cp] >= highest[2*cp+1](high) then
    LH = 1
    endif
    if low[cp] <= lowest[2*cp+1](low)  then
    LL= -1
    endif
    //
    IF LL < 0 AND Not LongOnMarket THEN
    BUY 1 CONTRACT AT MARKET
    ELSIF LH > 0 AND Not ShortOnMarket THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    //*********************************************************************************
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (righe 17- 56), with the addition of DISTANCE
    //
    //trailing stop function
    trailingstart = 25  //20  trailing will start @trailinstart points profit
    trailingstep  = 25  //25  trailing step to move the "stoploss"
    distance      = 10  //10  pips distance from caurrent price (if required by the broker)
    //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
    IF LongOnMarket THEN
    IF (close + distance) > newSL THEN
    SELL AT newSL STOP
    ELSIF (close - distance) < newSL THEN
    SELL AT newSL LIMIT
    ELSE
    SELL AT Market
    ENDIF
    ELSIF ShortOnmarket THEN
    IF (close + distance) < newSL THEN
    EXITSHORT AT newSL STOP
    ELSIF (close - distance) > newSL THEN
    EXITSHORT AT newSL LIMIT
    ELSE
    EXITSHORT AT Market
    ENDIF
    ENDIF
    ENDIF
    //*********************************************************************************
    Frattali-1.itf
    #171394 quote
    Gael
    Participant
    Average

    Grazie mille Roberto

    #171585 quote
    robertogozzi
    Moderator
    Master

    RENKO
    ———

    Provato sul DAX, 5 minuti:

     

    // Renko
    //
    // https://www.prorealcode.com/topic/initialising-renko-charts/#post-131050
    //
    
    once boxsize  = 50 * pointsize                      //50
    once renkoMax = ROUND(close / boxSize) * boxSize
    once renkoMin = renkoMax - boxSize
    IF close crosses over renkoMax + boxSize THEN
    WHILE close > renkoMax + boxSize
    renkoMax = renkoMax + boxSize
    renkoMin = renkoMin + boxSize
    Bullish = 1
    Bearish = 0
    WEND
    ELSIF close crosses under renkoMin - boxSize THEN
    WHILE close < renkoMin - boxSize
    renkoMax = renkoMax - boxSize
    renkoMin = renkoMin - boxSize
    Bullish = 0
    Bearish = 1
    WEND
    ENDIF
    IF Bullish AND Not LongOnMarket THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    IF Bearish AND Not ShortOnMarket THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    //*********************************************************************************
    // Nicolas'code  (with the addition of DISTANCE)
    //
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (righe 17- 56)
    //
    //trailing stop function
    IF (BarIndex - TradeIndex) >= 0 THEN                                 //0
    trailingstart = 25  //25  trailing will start @trailinstart points profit
    trailingstep  = 25  //10  trailing step to move the "stoploss"
    distance      = 10  //10  pips distance from caurrent price (if required by the broker)
    //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
    IF LongOnMarket THEN
    IF (close + distance) > newSL THEN
    SELL AT newSL STOP
    ELSIF (close - distance) < newSL THEN
    SELL AT newSL LIMIT
    ELSE
    SELL AT Market
    ENDIF
    ELSIF ShortOnmarket THEN
    IF (close + distance) < newSL THEN
    EXITSHORT AT newSL STOP
    ELSIF (close - distance) > newSL THEN
    EXITSHORT AT newSL LIMIT
    ELSE
    EXITSHORT AT Market
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    //*********************************************************************************
    thanked this post
    Renko.itf
    #171634 quote
    Gael
    Participant
    Average

    Grazie mille Roberto, sempre disponibile. Buona serata

    #171837 quote
    robertogozzi
    Moderator
    Master

    Ecco il terzo (l’ho provato sul DAX, Giornaliero):

    // HA & AO
    //
    // https://www.prorealcode.com/topic/initialising-renko-charts/#post-131050
    //
    // definizione Heikin-Ashi
    ONCE xOpen  = open
    xClose      = (Open + High + Low + Close) / 4
    IF BarIndex > 0 THEN
    xOpen    = (xOpen[1] + xClose[1]) / 2
    ENDIF
    Bullish     = xClose > xOpen //HA rialzista
    Bearish     = xClose < xOpen //HA ribassista
    // definizione dell'Awesome Oscillator
    ONCE FastMM = 5              //5   Fast Average
    ONCE SlowMM = 34             //34  Slow Average
    //AO        = Average[FastMM,0](xClose) - Average[SlowMM,0](xClose) //AO con Heikin-Ashi
    AO          = Average[FastMM,0](close) - Average[SlowMM,0](close)   //AO normale
    BullAO      = AO > AO[1]     //AO rialzista
    BearAO      = AO < AO[1]     //AO ribassista
    // entrtata LONG
    IF Bullish AND BullAO AND Not LongOnMarket THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    // entrata SHORT
    IF Bearish AND BearAO AND Not ShortOnMarket THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    //*********************************************************************************
    // Nicolas'code  (with the addition of DISTANCE)
    //
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (righe 17- 56)
    //
    //trailing stop function
    IF (BarIndex - TradeIndex) >= 0 THEN                                 //0
    trailingstart = 25  //25  trailing will start @trailinstart points profit
    trailingstep  = 25  //10  trailing step to move the "stoploss"
    distance      = 10  //10  pips distance from caurrent price (if required by the broker)
    //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
    IF LongOnMarket THEN
    IF (close + distance) > newSL THEN
    SELL AT newSL STOP
    ELSIF (close - distance) < newSL THEN
    SELL AT newSL LIMIT
    ELSE
    SELL AT Market
    ENDIF
    ELSIF ShortOnmarket THEN
    IF (close + distance) < newSL THEN
    EXITSHORT AT newSL STOP
    ELSIF (close - distance) > newSL THEN
    EXITSHORT AT newSL LIMIT
    ELSE
    EXITSHORT AT Market
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    //*********************************************************************************
    Il-Mio-Sistema-HA-AO.itf
    #171873 quote
    robertogozzi
    Moderator
    Master

    Ecco il quarto (provato sul DAX, h1):

    // Renko & Frattali
    //
    // https://www.prorealcode.com/topic/trading-system-1-1/
    //
    DEFPARAM CumulateOrders = False
    //------------------------------------------------------------------------------------
    // frattali
    cp = 2           //2  (default)
    BullFractal = 0
    BearFractal = 0
    if high[cp] >= highest[2*cp+1](high) then
    BullFractal = 1
    endif
    if low[cp] <= lowest[2*cp+1](low)  then
    BearFractal = 1
    endif
    //------------------------------------------------------------------------------------
    // Renko boxes
    once boxsize  = 50 * pointsize                      //50
    once renkoMax = ROUND(close / boxSize) * boxSize
    once renkoMin = renkoMax - boxSize
    Bullish = 0
    Bearish = 0
    IF close crosses over renkoMax + boxSize THEN
    WHILE close > renkoMax + boxSize
    renkoMax = renkoMax + boxSize
    renkoMin = renkoMin + boxSize
    Bullish = 1
    WEND
    ELSIF close crosses under renkoMin - boxSize THEN
    WHILE close < renkoMin - boxSize
    renkoMax = renkoMax - boxSize
    renkoMin = renkoMin - boxSize
    Bearish = 1
    WEND
    ENDIF
    //------------------------------------------------------------------------------------
    //
    IF BullFractal AND Bullish AND Not LongOnMarket THEN
    BUY 1 CONTRACT AT MARKET
    ELSIF BearFractal AND Bearish AND Not ShortOnMarket THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    // uscita Long
    IF Bullish AND LongOnMarket  THEN    //uscire al primo mattoncino inverso dopo l'entrata
    SELL AT Market
    ENDIF
    // uscitaShort
    IF Bearish AND ShortOnMarket THEN    //uscire al primo mattoncino inverso dopo l'entrata
    SELL AT Market
    ENDIF
    //*********************************************************************************
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (righe 17- 56), with the addition of DISTANCE
    //
    //trailing stop function
    trailingstart = 25  //20  trailing will start @trailinstart points profit
    trailingstep  = 25  //25  trailing step to move the "stoploss"
    distance      = 10  //10  pips distance from caurrent price (if required by the broker)
    //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
    IF LongOnMarket THEN
    IF (close + distance) > newSL THEN
    SELL AT newSL STOP
    ELSIF (close - distance) < newSL THEN
    SELL AT newSL LIMIT
    ELSE
    SELL AT Market
    ENDIF
    ELSIF ShortOnmarket THEN
    IF (close + distance) < newSL THEN
    EXITSHORT AT newSL STOP
    ELSIF (close - distance) > newSL THEN
    EXITSHORT AT newSL LIMIT
    ELSE
    EXITSHORT AT Market
    ENDIF
    ENDIF
    ENDIF
    //*********************************************************************************
    Renko-Frattali.itf
    #171884 quote
    robertogozzi
    Moderator
    Master

    Ecco il quinto ed ultimo codice (è la strategia scritta da verdi55 https://www.prorealcode.com/prorealtime-trading-strategies/point-figure-charts-automated-trading-system/, con qualche piccola modifica e l’aggiunta del trailing stop di Ncolas):

    //https://www.prorealcode.com/prorealtime-trading-strategies/point-figure-charts-automated-trading-system/
    //
    defparam cumulateorders = false
    //
    ONCE n         = 1                 //Number of lots
    ONCE uptrend   = 1
    ONCE downtrend = 1
    ONCE Boxsize   = 20                //Box size
    //
    turnafternn = 4
    LowerBorderBox = round((close / Boxsize) - 0.5) * Boxsize
    ONCE DowntrendLow = LowerBorderBox
    ONCE UptrendHigh = LowerBorderBox
    
    If LowerBorderBox > LowerBorderBox[1] then
    If uptrend = 1 then
    downtrend = 0
    ONCE DowntrendLow = LowerBorderBox
    If LowerBorderBox > UptrendHigh then
    UptrendHigh = LowerBorderBox
    endif
    endif
    If downtrend = 1 and LowerBorderBox >= DowntrendLow + (turnafternn * Boxsize) then
    UptrendHigh = LowerBorderBox
    uptrend = 1
    downtrend = 0
    endif
    elsif LowerBorderBox < LowerBorderBox[1] then
    If downtrend = 1 then
    uptrend = 0
    ONCE UptrendHigh = LowerBorderBox
    If LowerBorderBox < DowntrendLow then
    DowntrendLow = LowerBorderBox
    endif
    endif
    If uptrend = 1 and LowerBorderBox <= UptrendHigh - (turnafternn * Boxsize) then
    DowntrendLow = LowerBorderBox
    uptrend = 0
    downtrend = 1
    endif
    endif
    If uptrend = 1 and uptrend[1] = 0 AND Not LongOnMarket then
    buy n contracts at market
    endif
    If downtrend = 1 and downtrend[1] = 0 AND Not ShortOnMarket then
    sellshort n contracts at market
    endif
    set stop ploss 50
    //*********************************************************************************
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (righe 17- 56), with the addition of DISTANCE
    //
    //trailing stop function
    trailingstart = 25  //20  trailing will start @trailinstart points profit
    trailingstep  = 25  //25  trailing step to move the "stoploss"
    distance      = 10  //10  pips distance from caurrent price (if required by the broker)
    //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
    IF LongOnMarket THEN
    IF (close + distance) > newSL THEN
    SELL AT newSL STOP
    ELSIF (close - distance) < newSL THEN
    SELL AT newSL LIMIT
    ELSE
    SELL AT Market
    ENDIF
    ELSIF ShortOnmarket THEN
    IF (close + distance) < newSL THEN
    EXITSHORT AT newSL STOP
    ELSIF (close - distance) > newSL THEN
    EXITSHORT AT newSL LIMIT
    ELSE
    EXITSHORT AT Market
    ENDIF
    ENDIF
    ENDIF
    //*********************************************************************************
    Point-Figure.itf
    #171974 quote
    Gael
    Participant
    Average

    Grazie mille Roberto, gentilissimo

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

Trading system 1.1 point & figure


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Gael @gael Participant
Summary

This topic contains 12 replies,
has 2 voices, and was last updated by Gael
4 years, 7 months ago.

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