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.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by david196, Today, 09:09 PM
    0 responses
    6 views
    0 likes
    Last Post david196  
    Started by kkc2015, Today, 08:50 PM
    0 responses
    4 views
    0 likes
    Last Post kkc2015
    by kkc2015
     
    Started by fscabrera03, Today, 06:55 PM
    0 responses
    11 views
    0 likes
    Last Post fscabrera03  
    Started by LorraineP, Today, 04:02 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by NTPlayer, Today, 01:18 PM
    1 response
    25 views
    0 likes
    Last Post NinjaTrader_Kate  
    Working...
    X