Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong(Convert.ToInt32(DefaultQuantity), @"myEntryOrder") is not getting executed

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

    EnterLong(Convert.ToInt32(DefaultQuantity), @"myEntryOrder") is not getting executed

    Not sure why my EnterLong is getting executed at certain time:
    protected override void OnBarUpdate()
    {

    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;


    // Set 1
    if
    // Condition group 1
    (
    Times[0][0].TimeOfDay == new TimeSpan(dealStartingTime.HOUR,dealStartingTime.MI N,00)
    )
    {
    soldLong=0;canShort=0;
    Print("NQ Algorithm Testing- Step 4");
    Print (Times[0][0].TimeOfDay);
    Print (DefaultQuantity);


    EnterLong(Convert.ToInt32(DefaultQuantity), @"myEntryOrder");
    SetStopLoss(CalculationMode.Currency, equityDeal.MAXLOSS);

    }
    }
    }

    This part of the code is not getting executed. Can someone help me

    Log says:
    2019-04-15 18:16:57 Default Strategy 'NQAlgorithmTesting/134788298': An order placed at '2019-04-09 18:18:00' has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met.

    2019-04-15 18:16:57 Default Strategy 'NQAlgorithmTesting/134788298': Stop/target handling set to 'By strategy position' since currency based stop order was placed.
    This part of the code is not getting executed. Can someone help me?

    #2
    In addition, i get the following warning message and strategy is not green:
    2019-04-15 20:57:28 Default Strategy 'NQAlgorithm/134788278': Stop/target handling set to 'By strategy position' since currency based stop order was placed.
    Attached Files

    Comment


      #3
      Hello prabbala,

      Thanks for your post and welcome to the NinjaTrader forums!

      It looks like you are using Print statements to debug and you are saying, "This part of the code is not getting executed". In that case, what you want to do is add a print statement above the if statement and print out the values being used in the if statement. The if statement is checking to see if the current bar time is exactly equal to some time from some variable and I suggest print the bar time as well as the dealStartingTime.HOUR and dealStartingTime.MI N,00 to make sure you are not assuming something is true that may not ever be true. If you are using non-time based bars, such as range or renko, you may never match a particular time for a bar close, so print both the bar time and the assumed values will help clarify what the code is working with.

      The first log message is advising though that the strategy condition was true within the first 20 bars which is the default for BarsRequiredToTrade. To prevent this message, at the top of OnBarUpdate() you can add the condition: if (CurrentBar < BarsRequiredToTrader) return;

      The second message is just advising that it has taken an action to change the Stop/Target Handling based on how the Strategy was written. It is an expected message/behavior and is not a bug.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      86 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      151 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      79 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      53 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      61 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X