TS STRATEGIA DI HULL

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #184114 quote
    Gaspare
    Participant
    Veteran

    Ciao Roberto….auguri di fine anno e che il prossimo sia migliore

    vorrei, se possibile, un TS con la media di Hull,

    con stop and reverse ogni volta che la media cambia colore

    da usare su qualsiasi TF.

    Grazie

    #184120 quote
    robertogozzi
    Moderator
    Master

    Eccola:

    HullMA  = average[20,7](close)
    Bullish = HullMA > HullMA[1]
    Bearish = HullMA < HullMA[1]
    IF Bullish AND Not LongOnMarket THEN
       BUY 1 CONTRACT AT Market
    ELSIF Bearish AND Not ShortOnMarket THEN
       SELLSHORT 1 CONTRACT AT Market
    ENDIF
    #186341 quote
    Gaspare
    Participant
    Veteran
    DEFPARAM CumulateOrders = false
    
    MHull = HullAverage[ U ](close)
    MyAdx = Adx [ 5 ] > A
    
    If MHULL > MHULL[1]  and MHULL[1]  < MHULL[2] and MyAdx and not LongOnMarket then
    Buy 1 contract at Market
    Elsif  MHULL < MHULL[1] and MHULL[1]  > MHULL[2]  and MyAdx and not ShortOnMarket then
    Sellshort 1 contract at Market
    Endif
    //SET STOP pLOSS      100
    //SET TARGET pPROFIT  100
    

    Ciao Roberto

    per favore puoi inserire un’istruzione di ritracciamento prima di aprire posizioni?

    cioè quando la media di Hull cambia colore, diventa verde, allora vorrei aspettare un ritracciamento e alla prossima candela verde si va long,

    al contrario quando la media diventa rossa, allora si aspetta un ritracciamento e alla prossima candela rossa si va short.

    Le posizioni aperte si chiudono in stop and reverse

    Grazie

    #186396 quote
    Gaspare
    Participant
    Veteran

    scusa Roberto

    pensavo di chiudere le posizioni anche in trailing stop

    inserendo uno stop ATR in funzione della volatilita’.

    Io non so come fare, grazie

    #186542 quote
    robertogozzi
    Moderator
    Master

    Puoi fare un esempio?

    #186563 quote
    Gaspare
    Participant
    Veteran
    DEFPARAM CumulateOrders = false
    
    MHull = HullAverage[ U ](close)
    MyAdx = Adx [ 5 ] > A
    
    If MHULL > MHULL[1]  and MHULL[1]  < MHULL[2] and MyAdx and not LongOnMarket then
    Buy 1 contract at Market
    Elsif  MHULL < MHULL[1] and MHULL[1]  > MHULL[2]  and MyAdx and not ShortOnMarket then
    Sellshort 1 contract at Market
    Endif
    SET STOP pLOSS      25
    //trailing stop function
    trailingstart = B //trailing will start @trailinstart points profit
    trailingstep = C //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
    

    Eccolo

    #186566 quote
    robertogozzi
    Moderator
    Master

    Questo lo conosco, ma conm l’ATR cosa vorresti fare, quando dovrebbe uscire?

    #186567 quote
    Gaspare
    Participant
    Veteran

    non lo so, vedi tu se possibile… grazie

    cmq penso che basti se aggiungi il ritracciamento.

    #186768 quote
    Gaspare
    Participant
    Veteran

    Scusa se disturbo….

    ma posso avere una risposta,

    positiva o negativa che sia?

    Grazie

    #186770 quote
    robertogozzi
    Moderator
    Master

    Certo che è possibile, devi solo avere un pò di pazienza.

    #186994 quote
    robertogozzi
    Moderator
    Master

    Ecco fatto:

    DEFPARAM CumulateOrders = false
    IF Not OnMarket THEN
    StopLossL = 0
    StopLossS = 9999999
    ENDIF
    MHull = HullAverage[20](close)
    MyAdx = Adx [5] > 20
    If MHULL > MHULL[1]  and MHULL[1]  < MHULL[2] and MyAdx and not LongOnMarket then
    Buy 1 contract at Market
    Elsif  MHULL < MHULL[1] and MHULL[1]  > MHULL[2]  and MyAdx and not ShortOnMarket then
    Sellshort 1 contract at Market
    Endif
    //SET STOP pLOSS      100
    //SET TARGET pPROFIT  100
    Atr = averagetruerange[50](close)
    TrailStart = 30
    Profitto = PositionPrice * PositionPerf / PipSize
    IF Profitto >= TrailStart * PipSize THEN
    IF StopLossL = 0 AND StopLossS = 9999999 THEN
    StopLossL = PositionPrice + Atr
    StopLossS = PositionPrice - Atr
    ENDIF
    ENDIF
    IF Profitto >= TrailStart * PipSize THEN
    IF LongOnMarket AND close > (StopLossL + Atr + TrailStart) THEN
    StopLossL = StopLossL + Atr
    ELSIF ShortOnMarket AND close < (StopLossS - Atr - TrailStart) THEN
    StopLossS = StopLossS - Atr
    ENDIF
    ENDIF
    IF LongOnMarket AND StopLossL > 0 THEN
    SELL AT StopLossL STOP
    ELSIF ShortOnMarket AND StopLossS < 9999999 THEN
    EXITSHORT AT StopLossS STOP
    ENDIF
    //graphonprice StopLossL coloured(255,0,0,255)
    //graphonprice StopLossS coloured(0,0,255,255)
    //graph Profitto
    Il-Mio-Sistema-5.itf
    #189366 quote
    Gaspare
    Participant
    Veteran
    DEFPARAM CumulateOrders = false
    //Defparam Flatbefore=080000
    //Defparam Flatafter=220000
    HullMA  = average[ 34 ,7](close)
    Bullish = HullMA > HullMA[1] and HULLMA[1]  < HULLMA[2]
    Bearish = HullMA < HullMA[1] and HULLMA[1]  > HULLMA[2]
    IF Bullish  AND Not LongOnMarket THEN
    BUY 1 CONTRACT AT Market
    ELSIF Bearish  AND Not ShortOnMarket THEN
    SELLSHORT 1 CONTRACT AT Market
    ENDIF
    //SET STOP pLOSS      20
    //SET TARGET pPROFIT  40
    

    Ciao Roberto

    per favore puoi inserire un’istruzione di ritracciamento prima di aprire posizioni?

    cioè quando la media di Hull cambia colore, diventa verde, allora vorrei aspettare un ritracciamento e alla prossima candela verde si va long,

    al contrario quando la media di Hull diventa rossa, allora si aspetta un ritracciamento e alla prossima candela rossa si va short.

    Le posizioni aperte si chiudono in stop and reverse

    Grazie

    #189395 quote
    robertogozzi
    Moderator
    Master

    Ecco il codice:

    DEFPARAM CumulateOrders = false
    ONCE SegnaleLong  = 0
    ONCE SegnaleShort = 0
    ONCE PullBack     = 0
    HullMA  = average[ 34 ,7](close)
    Bullish = HullMA > HullMA[1] and HULLMA[1]  < HULLMA[2]
    Bearish = HullMA < HullMA[1] and HULLMA[1]  > HULLMA[2]
    IF Bullish THEN
       SegnaleShort = 0
       SegnaleLong  = 1
       PullBack     = 0
    ENDIF
    IF Bearish THEN
       SegnaleShort = 1
       SegnaleLong  = 0
       PullBack     = 0
    ENDIF
    IF SegnaleLong  AND PullBack = 0 THEN
       IF close < open THEN
          PullBack = 1
       ENDIF
    ENDIF
    IF SegnaleShort AND PullBack = 0 THEN
       IF close > open THEN
          PullBack = 1
       ENDIF
    ENDIF
    IF SegnaleLong  AND PullBack AND close > open AND Not LongOnMarket THEN
       BUY 1 CONTRACT AT Market
    ENDIF
    IF SegnaleShort AND PullBack AND close < open AND Not ShortOnMarket THEN
       SELLSHORT 1 CONTRACT AT Market
    ENDIF
    Gaspare thanked this post
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.

TS STRATEGIA DI HULL


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Gaspare @gaspare Participant
Summary

This topic contains 12 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 11 months ago.

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