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;

    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.

        Comment


          #5
          I see. Okay, thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          21 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          30 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          50 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          40 views
          0 likes
          Last Post CarlTrading  
          Working...
          X