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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 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
      119 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