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 Mestor, 03-10-2023, 01:50 AM
      16 responses
      388 views
      0 likes
      Last Post z.franck  
      Started by rtwave, 04-12-2024, 09:30 AM
      4 responses
      31 views
      0 likes
      Last Post rtwave
      by rtwave
       
      Started by yertle, Yesterday, 08:38 AM
      7 responses
      29 views
      0 likes
      Last Post yertle
      by yertle
       
      Started by bmartz, 03-12-2024, 06:12 AM
      2 responses
      22 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by funk10101, Today, 12:02 AM
      0 responses
      7 views
      0 likes
      Last Post funk10101  
      Working...
      X