Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
      Paul H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by zstheorist, Today, 07:52 PM
      0 responses
      3 views
      0 likes
      Last Post zstheorist  
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      149 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Working...
      X