stop loss che si fissi

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #215873 quote
    Ciccarelli Franco
    Participant
    Junior

    Mi piacerebbe uno stop löss che si fissi ad un certo numero di punti dal profit, sia in positivo che in negativo. Forse la cosa già esiste, magari in maniera diversa.

    Comunque sarebbe bello avere uno stop che si aggiorni ad ogni candela.

     

    Grazie

    #215875 quote
    robertogozzi
    Moderator
    Master

    Si può aggiornare ogni candela, ma su quale base? Pips, Atr o altro?

    #215876 quote
    Ciccarelli Franco
    Participant
    Junior

    Pips

    Grazie

    #215877 quote
    Ciccarelli Franco
    Participant
    Junior

    Anche atr, ma non so come funzionerebbe,

    Grazie

    #215948 quote
    Ciccarelli Franco
    Participant
    Junior

    Non lo ritieni interessante da fare?

    #215953 quote
    robertogozzi
    Moderator
    Master

    Questo è in pips, e ad ogni candela si aggiorna. Se inizi con 50 pips di stop (esempio Long), se il prezzo va su, alla candela successiva lo stoip loss sarà sempre di 50 pip, ma calcolati dal prezzo corrente, non quello iniziale. Se arrivi ad un profitto di 60 pips, allora lo stop loss sarà a +10 pips di profitto (sempre 50 pips di distanza dal prezzo attuale):

    SL  = 150
    TP  = SL * 3
    Sma = average[20,0](close)
    IF Not OnMarket THEN
       IF close CROSSES OVER Sma THEN
          BUY AT MARKET
          StopLoss   = close - SL*PipSize
          TakeProfit = close + TP*PipSize
       ELSIF close CROSSES UNDER Sma THEN
          SELLSHORT AT MARKET
          StopLoss   = close + SL*PipSize
          TakeProfit = close - TP*PipSize
       ENDIF
    ELSE
       IF LongOnMarket THEN
          StopLoss   = max(StopLoss,close - SL*PipSize)
       ELSIF ShortOnMarket THEN
          StopLoss   = min(StopLoss,close + SL*PipSize)
       ENDIF
    ENDIF
    SET TARGET PRICE TakeProfit
    SET STOP   PRICE StopLoss
    //graphOnPrice TakeProfit coloured("Blue")
    //graphonprice StopLoss   coloured("Red")
    //graph (close - StopLoss) / PipSize
    #215955 quote
    phoentzs
    Participant
    Master

    Scusa, non sono un grande programmatore. Ma se il prezzo scende di nuovo, anche lo SL non torna indietro e rimane alla stessa distanza e i pip guadagnati vengono persi di nuovo? O mi sono perso qualcosa?

    #215958 quote
    Ciccarelli Franco
    Participant
    Junior

    Sempre gentilissimo, lo provo.

    Grazie

    #215997 quote
    robertogozzi
    Moderator
    Master

    Le linee 16 e 18 servono proprio a non fare tornare indietro lo Stop Loss.

    phoentzs thanked this post
    #216161 quote
    phoentzs
    Participant
    Master

    È possibile ottenere lo stesso codice con percentuale per favore?

    #216232 quote
    robertogozzi
    Moderator
    Master

    Eccolo in percentuale:

    SLpercent = 1.0
    TPpercent = SLpercent * 3.0
    Sma = average[20,0](close)
    IF Not OnMarket THEN
       IF close CROSSES OVER Sma THEN
          BUY AT MARKET
          SL        = (close * SLpercent / 100) / PipSize
          TP        = (close * TPpercent / 100) / PipSize
          StopLoss   = close - SL
          TakeProfit = close + TP
       ELSIF close CROSSES UNDER Sma THEN
          SELLSHORT AT MARKET
          SL        = (close * SLpercent / 100) / PipSize
          TP        = (close * TPpercent / 100) / PipSize
          StopLoss   = close + SL
          TakeProfit = close - TP
       ENDIF
    ELSE
       IF LongOnMarket THEN
          StopLoss   = max(StopLoss,close - SL*PipSize)
       ELSIF ShortOnMarket THEN
          StopLoss   = min(StopLoss,close + SL*PipSize)
       ENDIF
    ENDIF
    SET TARGET PRICE TakeProfit
    SET STOP   PRICE StopLoss
    //graphOnPrice TakeProfit coloured("Blue")
    //graphonprice StopLoss   coloured("Red")
    //graph (close - StopLoss) / PipSize
    phoentzs thanked this post
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

stop loss che si fissi


ProOrder: Trading Automatico & Backtesting

New Reply
Summary

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

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