Dubbio sullo stop loss

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #133112 quote
    Frank
    Participant
    Junior

    Buongiorno,

    ho un dubbio da neofita che mi attanaglia. Vorrei impostare probacktest in un setup con azioni utilizzando un timeframe giornaliero, quindi l’eventuale decisione di acquisto o vendita avverrebbe il giorno successivo a quello della seduta.

    Limito ogni trade a un massimo di 200 dollari. Vorrei calcolare lo stop loss in maniera tale che corrisponda a 1,5 volte l’ATR e comprare un numero di azioni che dipende dall’ATR per circoscrivere l’eventuale perdita a questo range specifico. Per cui, se ho capito bene, dovro’ scrivere:

    stoploss = 1.5*ATR
    
    IF (Condizioni) then BUY (200/stoploss) SHARES AT MARKET TOMORROWOPEN
    
    SET STOP LOSS stoploss

    Mi chiedo:

    1. Se volessi acquistare le azioni STOP anzichè AT MARKET ha senso scriverlo nel backtest o è indifferente nella simulazione?
    2. Se volessi vendere le azioni LIMIT anzichè AT MARKET ha senso scriverlo nel backtest o è indifferente nella simulazione?
    3. Non mi è chiaro se per fissare lo stop loss corretto, in questo caso specifico devo usare “STOP LOSS” oppure “STOP $LOSS” visto che lo stop loss è espresso in dollari e non in pips.

    Grazie in anticipo per il chiarimento.

    Frank

    #133115 quote
    robertogozzi
    Moderator
    Master

    Se devi usare ordini LIMIT e STOP devi metterli anche nel backtest, certo. Il backtest lo fai sulla strategia che poi userai in autotrading, quindi che senso avrebbe fare un backtest diverso dalla strategia reale?

    Lo StopLoss che hai calcolato tu con l’ATR non è in valuta, ma in differenza di prezzo, infatti l’ATR è un calcolo particolare del Range.

    Fai un calcolo strano, dividi le azioni da acquistare per il range di prezzo.

    Non ho ben capito cosa desideri fare. O meglio come vuoi esattamente determinare la tua position size.

    #133130 quote
    Frank
    Participant
    Junior

    OK Roberto, cerco di spiegarmi meglio. Per quanto riguarda il position size, mi riferisco a quanto ho letto in questo articolo:

    https://therichmoose.com/post20180928/

    These are the steps to identify all the components you need to complete a proper calculation of
    maximum position size using Average True Range.
    1. (R) Determine the maximum amount of equity you are willing to lose for each trade. This
    should be based on your total account equity at the time you enter the trade. (New traders
    should risk less than 1 percent per trade.)
    2. (P) Identify the current price of the security. I do most of my trade entries near the end of
    the trading day as volume tends to be higher. If you do your calculations after hours, use the
    closing price of the security.
    3. (V) Calculate the previous 20-day ATR. You do not need to calculate this manually. Just use a
    trading platform, your brokerage account trading window, or even Yahoo Finance. I choose 20
    days because it is a sufxcient time period (4 weeks) to get a good feel for recent market activity.
    4. (X) Determine your ATR multiple. Your ATR multiple will form the xrst stop loss on your
    position. A more patient, less active trader could use an ATR multiple which is 5 times the
    current 20-day ATR. A more active trader may choose an ATR multiple which is 3 times the
    current 20-day ATR.
    The calculation for ATR-based maximum position size is as follows:
    R/(V*X) = U (Total Number of Units)
    U*P = Max Position
    or, in a single calculation:
    [R/(V*X)]*P = Max Position

    Quindi, quello che sto cercando di fare è trovare il numero massimo di azioni da acquistare volendo spendere al massimo 200 dollari per trade basandomi sull’ATR.

    E’ sbagliato impostarlo cosi?

    IF (Condizioni) then BUY (200/stoploss) SHARES AT MARKET TOMORROWOPEN

    Per quanto riguarda lo stop loss, l’idea è quella di calcolarlo come (prezzo di chiusura dell’azione – 1,5*ATR), è sbagliato scriverlo cosi?

    stoploss = 1.5*ATR
    
    SET STOP LOSS stoploss

    Inoltre, no so se usare “STOP LOSS” oppure “STOP $LOSS”

    Per quanto invece riguarda le vendite e gli acquisti stop al posso di “sell at market” posso quindi scrivere cosi’?

    IF (Condizioni) then BUY X SHARES STOP TOMORROWOPEN
    

    Mi rendo conto che forse queste domande sono un po’ ingenue, ma sto imparando.  Grazie in anticipo per i tuoi preziosi chiarimenti.

    #133168 quote
    robertogozzi
    Moderator
    Master
    #133178 quote
    Frank
    Participant
    Junior

    Grazie Roberto,

    ho fatto diverse ricerche, questo è il codice che ho ricavato in base alla mia comprensione

    ATR = AverageTrueRange[14](Close)
    
    sl = 1.5*ATR
    tp = 3*ATR
    
    equity = 10000
    maxrisk = round(equity*0.02)
    
    PositionSize = abs(round((maxrisk/sl)))
    
    IF (condizioni) AND not daysForbiddenEntry AND NOT ONMARKET THEN
    
    buy PositionSize SHARES at close stop
    
    set stop loss sl
    set target profit tp
    
    ENDIF

    Ammesso che tutto quello che ho scritto sia corretto, non mi è ancora chiaro se i comandi stop loss e take profit sono esatti o andrebbero usati $loss e $profit, o addirittura ploss e pprofit. Ti ricordo che il tutto verrebbe inserito in un timeframe daily per investimento in azioni. Grazie.

    #133211 quote
    robertogozzi
    Moderator
    Master

    Vanno bene LOSS e PROFIT.

    Il simbolo “$” si usa quando si deve specificare un valore monetario, mentre “p” quando si indicano pips. In questo caso tu usi una differenza di prezzo (ATR) quindi va bene la forma che hai usato.

    Frank thanked this post
    #133212 quote
    Frank
    Participant
    Junior

    Grazie!

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

Dubbio sullo stop loss


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Frank @fmuratori Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by Frank
5 years, 8 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 05/25/2020
Status: Active
Attachments: No files
Logo Logo
Loading...