Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Not catching all entries, please can someone help with an explanation.

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

    Not catching all entries, please can someone help with an explanation.

    I am playing with the following code. when i run the strategy it makes entries for UT UT IN and DT DT IN within startTradingInTime and endTradingInTime as expected. However, it does not enter trades for UT UT OUT and DT DT OUT within the second timeframe being startTradingOutTime and endTradingOutTime. However, there are a few sporadic UT UT OUT/DT DT OUT trades within the TradingInTime rather than the TradingOutTime.

    Can someone please explain my error?

    Much appreciated.




    Code:
    {
    
    if ((Position.MarketPosition == MarketPosition.Flat)
    && (ToTime(Time[0]) <= endTradingInTime)
    && (ToTime(Time[0]) >= startTradingInTime))
    
    {
    
    
    if ((XavTrend1 == 5)
    && (XavTrend2 == 5)
    && (ScalpTrader == 1)
    && (adxlong_in > ADXlong)
    && (dm.DiPlus[i]>dm.DiMinus[i])
    && (Close[0] > sma_in))
    
    {
    
    
    EnterLong(lots, "UT+UT IN");
    SetTrailStop("UT+UT IN",CalculationMode.Ticks,24,false);
    if (printtolog == true) Print("LONG TRADE UT UT IN-----------RGAuto:" );
    
    }
    
    
    if ((XavTrend1 == -5)
    && (XavTrend2 == -5)
    && (ScalpTrader == 2)
    && (adxshort_in > ADXshort)
    && (dm.DiPlus[i]<dm.DiMinus[i])
    && (Close[0] < sma_in))
    
    
    {
    
    EnterShort(lots, "DT+DT IN");
    SetTrailStop("DT+DT IN",CalculationMode.Ticks,24,false);
    if (printtolog == true) Print("SHORT TRADE UT UT IN-----------RGAuto:");
    
    
    }
    
    
    
    else if ((Position.MarketPosition == MarketPosition.Flat)
    && (ToTime(Time[0]) <= endTradingOutTime)
    && (ToTime(Time[0]) >= startTradingOutTime))
    
    
    if ((XavTrend1 == 5)
    && (XavTrend2 == 5)
    && (ScalpTrader == 1)
    && (adxlong_in > ADXlong)
    && (Close[0] > sma_in))
    
    {
    
    EnterShort(lots, "UT+UT OUT");
    if (printtolog == true) Print("SHORT TRADE UT UT OUT-----------RGAuto:");
    
    }
    
    
    if ((XavTrend1 == -5)
    && (XavTrend2 == -5)
    && (ScalpTrader == 2)
    && (adxshort_in > ADXshort)
    && (Close[0] < sma_in))
    
    {
    
    EnterLong(lots, "DT+DT OUT");
    if (printtolog == true) Print("LONG TRADE DT DT OUT-----------RGAuto:" );
    
    }
    
    
    }
    
    }

    #2
    Hello Jaxx2022,

    From looking just at the code we would not be able to tell what's wrong. This is a situation where you need to use prints like you are already to find what is happening.

    If you are not seeing the prints you added for the OUT then that indicates the parent condition was not true. You would have to add additional prints outside that condition to output the variables you used in the condition to see what's happening.

    If you see the print from inside your condition that may be that the order was ignored, you can use TraceOrders to observe that situation: https://ninjatrader.com/support/help...ub=traceorders

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    90 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    120 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X