Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 cre8able, Today, 01:16 PM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by chbruno, 04-24-2024, 04:10 PM
    3 responses
    47 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by samish18, Today, 01:01 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by WHICKED, Today, 12:56 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by WHICKED, Today, 12:45 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X