Stop dinamico

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #236181 quote
    IfontIfont
    Participant
    New

    Buenas noches,

    He lanzado un trading automático vinculado a IG y me da problemas. No me ejecuta las órdenes en Forex porque el stop dinamico estaba puesto a 10 puntos\tips. Pongo 11 y tampoco se ejecuta, da error. ¿Saben cual es el minimo que hay que poner??

    Gracias

    Albert

    #236192 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    El broker decide si hay un mínimo a respetar y cuánto es, para los diferentes instrumentos y activos, por lo que hay que consultar en su sitio web o llamarlo.
    ¿Qué error es?

    #236205 quote
    IfontIfont
    Participant
    New

    Buenos días,

    Trabajo con el broker IG. He estado revisando y en IG no es posible lanzar  directamente una órden al mercado con stop dinámico. Inicialmente hay que fijar un stop loss standard y luego editar la operación en curso y ponerlo en dinámico. Por lo tanto, inicialmente no creo sea posible lanzar la orden con el sistema automático.

    ¿es posible fijar un stop loss y que se vaya modificando según la posición vaya teniendo beneficios?
    Por ejemplo, si voy ganando 5 puntos, que el stop suba otros 5 puntos y así succesivamente.

    Hracias

    Albert

    #236237 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Debes utilizar Stop Loss, en puntos, en porcentaje o en dinero.
    Debe agregar un trailing stop usando un código, no usando SET STOP TRAILING.
    Esta estrategia utiliza el trailing stop escrito hace varios años por Nicolas:

    Sma = average[20,0](close)
    UP  = close CROSSES OVER  Sma
    DN  = close CROSSES UNDER Sma
    Bullish = close > open
    Bearish = close < open
    IF UP AND Bullish AND Not OnMarket THEN
       BUY AT MARKET
    ELSIF DN AND Bearish AND Not OnMarket THEN
       SELLSHORT AT MARKET
    ENDIF
    ONCE SL = 0.3
    ONCE TP = SL * 2
    SET STOP   %LOSS   SL
    SET TARGET %PROFIT TP
    //
    //************************************************************************
    // trailing stop function      (by Nicolas)
    //
    // lines 17-56 at https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    //
    trailingstart = 20   //trailing will start @trailinstart points profit
    trailingstep  = 5    //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
    //************************************************************************
    #236247 quote
    IfontIfont
    Participant
    New

    Hola Roberto,

    Gracias por tu mensaje. Efectivamente ya encontré este código aquí en el foro pero me parece no funciona exactamente como un stop dinámico y no es lo que buscaba. Si no me equivoco, el stop se sube siempre directamente  al precio de entrada más el “trailingstep” y por lo tanto, pasas de un stop para reducir pérdidas y que va subiendo poco a poco según si vas a favor del mercado a un stop para asegurar una ganancia y en seguida se cierra la posición.

    Gracias a vuestro aporte he modificado el código a un stop dinámico de 10 puntos que tiene en cuenta el máximo de la última vela y me funciona bien. Aquí lo tienes por si os interesa (para Forex):

    ————————————————————————

    // Stops y targets
    SET STOP pLOSS 10

    //trailing stop function
    trailingstart = 3 //trailing will start @trailinstart points profit
    trailingstep = 3 //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 = High *0.999
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = High *0.999
    ENDIF
    ENDIF

    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = Low*1.001
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = Low*1.001
    ENDIF
    ENDIF

    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //************************************************************************

    GRAPH newSL as “trailing”

     

     

    Un saludos,

     

    Albert.

Viewing 5 posts - 1 through 5 (of 5 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

Stop dinamico


ProOrder: Trading Automático y Backtesting

New Reply
Author
author-avatar
Ifont @ifont Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by IfontIfont
2 years, 1 month ago.

Topic Details
Forum: ProOrder: Trading Automático y Backtesting
Language: Spanish
Started: 08/06/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...