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 NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    43 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    48 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X