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 Natoc, Today, 03:04 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by Rudy2323, Today, 02:56 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by tonynt, Yesterday, 02:07 PM
    1 response
    29 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by sgordet, Yesterday, 01:57 PM
    1 response
    30 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by PeterInBrisbane, Yesterday, 01:07 AM
    2 responses
    25 views
    0 likes
    Last Post PeterInBrisbane  
    Working...
    X