Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Annoying delay starting bot

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

    Annoying delay starting bot

    I really need my bot to simply activate WHEN I activate it. I do NOT want it thinking it is in the middle of some fictional trade and missing out on real opportunites because on startup it thinks it's already in one.

    My bot does things long term, and if it is waiting until a fictional trade is finished then it may be way too long into the day for it to be of any use!

    How do I get the bot to understand EVERYTHING IS ALREADY FLAT WHEN I TURNED IT ON???

    I appreciate any help, this has been annoying the heck out of me and makes testing take WAY longer than it should, as well!

    #2
    Hello Mistoffelees,

    Thank you for your post.

    To make sure the strategy is flat at the end of processing historical data, you can check the position on the last historical bar and either exit long or exit short.

    Code:
    if (State == State.Historical && CurrentBar == Count - 2)
    {
    if(Position.MarketPosition == MarketPosition.Long)
    //exit short
    else if (Position.MarketPosition == MarketPosition.Short)
    //exit long
    }
    Or if you don't want it to process historically at all, just include this check:

    Code:
    if (State == State.Historical) return;
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      I appreciate your help, but how do I do this in the Wizard?

      Also, if I have to unlock it, then where do I put the check: if (State == State.Historical) return; ?

      Comment


        #4
        If this is a Strategy Builder script, you will need to unlock the script and edit it in the Wizard.

        You would put that check at the top of the OnBarUpdate() method.
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          I see. Okay, thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Darkslide_Tom, Today, 11:08 PM
          0 responses
          6 views
          0 likes
          Last Post Darkslide_Tom  
          Started by wolfrine97, Today, 10:54 PM
          0 responses
          6 views
          0 likes
          Last Post wolfrine97  
          Started by sastrades, Today, 09:24 PM
          0 responses
          9 views
          0 likes
          Last Post sastrades  
          Started by techbid, 03-21-2025, 12:16 PM
          1 response
          14 views
          0 likes
          Last Post techbid
          by techbid
           
          Started by laketrader, 03-10-2025, 07:20 AM
          7 responses
          68 views
          0 likes
          Last Post laketrader  
          Working...
          X