PROGRAMACION STOP LOSS – AYUDA

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #139191 quote
    DALUPEZDALUPEZ
    Participant
    New

    HOLA. QUIERO PROGRAMAR EL STOP LOSS DE UN SISTEMA, QUIERO QUE EL STOP LOSS INICIAL ESTE 1% DEBAJO DEL MINIMO DE LAS ULTIMAS 5 VELAS. Y QUE LUEGO DE QUE EL PRECIO DE LA ACCION SUBA UN 10% POR EJ, EL STOP LOSS SE CORRA AL PRECIO DE ENTRADA, Y DESDE AHI APLICAR TRAILING STOP DE X%. ¿ES POSIBLE O NO? MUCHAS GRACIAS!

    #139196 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    NO escriba en mayúscula, excepto palabras simples u oraciones muy cortas para señalar algo.

    Se considera que las mayúsculas son gritos cuando se habla, según netiquette.

    Tiene poca educación y es más difícil de leer. Gracias 🙂

    #139233 quote
    DALUPEZDALUPEZ
    Participant
    New

    Hola…Gracias por tu comentario…lo tendre en cuenta….

    #139368 quote
    DALUPEZDALUPEZ
    Participant
    New

    Hola!! Alguien que me ayude…..

    #139369 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Este es mi código (no probado) para posiciones largas:

    If not OnMarket then
       NewStop  = 0
    Endif
    If not OnMarket then  //do not change while at market
       StopLoss = lowest [5](low) * 0.99  //-1%
    Endif
    MyProfit    = TradePrice * 1.1             //+10%
    Result      = TradePrice * (1 + PositionPerf)
    If NewStop > 0 Then
       MyProfit = NewStop * 1.05  //5% trailing stop
       If close >= MyProfit Then
          NewStop= MyProfit
       Endif
    Endif
    If NewStop = 0 and OnMarket and Result >= MyProfit Then
      NewStop   = TradePrice
    Endif
    If MyConditions and Not OnMarket then
       Buy 1 contract at Market
       Sell at StopLoss STOP
    Endif
    If OnMarket then
       Sell at max(StopLoss,NewStop) STOP
    Endif
    #139387 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I edit my code above to correct  a couple of errors.

    This is a complete MTF version for both Long and Short trades:

    DEFPARAM CumulateOrders = false
    //
    timeframe(1 day,updateonclose)
    CondL = close > average[200] AND average[10] CROSSES OVER  average[20]
    CondS = close < average[200] AND average[10] CROSSES UNDER average[20]
    //
    timeframe(default)
    If not OnMarket then
       NewStop  = 0
    Endif
    If not OnMarket then  //do not change while at market
       StopLossL = lowest [5](low)  * 0.99  //-1%
       StopLossS = highest [5](low) * 1.01  //+1%
    Endif
    IF LongOnMarket THEN
       MyProfit    = TradePrice * 1.10            //+10%
       Result      = TradePrice * (1 + PositionPerf)
    ELSIF ShortOnMarket THEN
       MyProfit    = TradePrice * 0.90            //-10%
       Result      = TradePrice * (1 - PositionPerf)
    ENDIF
    If NewStop <> 0 Then
       IF LongOnMarket THEN
          MyProfit = NewStop * 1.02  //2% trailing stop
          If close >= MyProfit Then
             NewStop= MyProfit
          Endif
       ELSIF ShortOnMarket THEN
          MyProfit = NewStop * 0.98  //2% trailing stop
          If close <= MyProfit Then
             NewStop= MyProfit
          Endif
       ENDIF
    Endif
    If NewStop = 0 THEN
       IF LongOnMarket and Result >= MyProfit Then
          NewStop   = TradePrice
       ELSIF ShortOnMarket and Result <= MyProfit Then
          NewStop   = TradePrice
       ENDIF
    Endif
    If CondL and Not OnMarket then
       Buy 1 contract at Market
       Sell at StopLossL STOP
    Endif
    If CondS and Not OnMarket then
       SellShort 1 contract at Market
       ExitShort at StopLossS STOP
    Endif
    If OnMarket then
       Sell      at max(StopLossL,NewStop) STOP
       ExitShort at min(StopLossS,NewStop) STOP
    Endif
    SET TARGET pPROFIT 50
Viewing 6 posts - 1 through 6 (of 6 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

PROGRAMACION STOP LOSS – AYUDA


Soporte Plataforma: Gráficos, Datos y Brokers

New Reply
Author
author-avatar
DALUPEZ @dalupez Participant
Summary

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

Topic Details
Forum: Soporte Plataforma: Gráficos, Datos y Brokers
Language: Spanish
Started: 07/13/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...