Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

error en una estrategia porque sale dos veces, y una es errada.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    error en una estrategia porque sale dos veces, y una es errada.

    Cordial Saludo.


    tengo una estrategia automatizada, que tiene el siguiente problemas, cuando entra en largo, y va a cerrar la operación ___
    ____ a veces sale dos veces porque tiene varios filtros de cierre , esto hace que de nuevo entre..... pero es una entrada fallida....
    Como hago para que salgo solo una ves si tiene

    copia parte del codigo:

    if ( EMA(SMALAJC)[0] + SMA(SMALAJC)[7] < EMA(SMALAJC)[7] + SMA(SMALAJC)[0]
    && Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= (stop / salidasExitLargoCON))

    {
    ExitLong("Exitlong4", "");
    }
    // Condition set 5.1 condicion de salida de la estrategia fallida.
    if ( EMA(SMALAJC)[0] + SMA(SMALAJC)[1] < EMA(SMALAJC)[1] + SMA(SMALAJC)[0]
    && Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) <= - (stop / salidasIndExitFallo))

    {
    ExitLong("ExitlongFallo4", "");
    } if ( EMA(SMALAJC)[0] + SMA(SMALAJC)[7] < EMA(SMALAJC)[7] + SMA(SMALAJC)[0]
    && Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= (stop / salidasExitLargoCON))

    {
    ExitLong("Exitlong4", "");
    }
    // Condition set 5.1 condicion de salida de la estrategia fallida.
    if ( EMA(SMALAJC)[0] + SMA(SMALAJC)[1] < EMA(SMALAJC)[1] + SMA(SMALAJC)[0]
    && Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) <= - (stop / salidasIndExitFallo))

    {
    ExitLong("ExitlongFallo4", "");
    }
    // Condition set 5.2 condicion de salida de la estrategia fallida.
    if ( EMA(SMALAJC)[0] + SMA(SMALAJC)[1] < EMA(SMALAJC)[1] + SMA(SMALAJC)[0]
    && Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= (stop / salidasExitLargoCON))

    {
    ExitLong("Exitlong5", "");
    // Condition set 5.2 condicion de salida de la estrategia fallida.
    if ( EMA(SMALAJC)[0] + SMA(SMALAJC)[1] < EMA(SMALAJC)[1] + SMA(SMALAJC)[0]
    && Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= (stop / salidasExitLargoCON))

    {
    ExitLong("Exitlong5", "");

    Mil Gracias

    Leonardo Jimčnez C.

    #2
    Hello Da vinci, thanks for your question.

    I am going to be using Google Translate to translate your message.

    In the managed approach, it is designed so that any Exit order will be ignored if an entry does not exist. So if you call ExitLong and the strategic position is flat, the ExitLong order will be ignored.

    You will need to add Prints to the strategy to find what's wrong. This part does not seem right to me, but this is just an assumption as I don't have full knowledge of the code:

    Code:
    ExitLong("Exitlong5", "");
    // Condition set 5.2 condicion de salida de la estrategia fallida.
    if ( EMA(SMALAJC)[0] + SMA(SMALAJC)[1] &lt; EMA(SMALAJC)[1] + SMA(SMALAJC)[0]
    &amp;&amp; Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) &gt;= (stop / salidasExitLargoCON))
    
    {
    ExitLong("Exitlong5", "");
    You are calling ExitLong twice here. If it continues to happen after debugging with prints, you will need to re-build the strategy and make sure it works for one Exit condition, then add the rest of the exits one by one. Also, you can check for the MarketPostition and check to make sure Position.MarketPosition is Long before calling ExitLong.

    Best regards.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    556 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X