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 ybforex, 03-11-2025, 05:30 PM
          11 responses
          99 views
          0 likes
          Last Post ybforex
          by ybforex
           
          Started by forgebench, Today, 02:22 PM
          2 responses
          9 views
          0 likes
          Last Post forgebench  
          Started by MamaKB, 02-14-2025, 03:38 PM
          10 responses
          84 views
          0 likes
          Last Post Fertryd2  
          Started by Irukandji, Today, 03:46 PM
          0 responses
          7 views
          0 likes
          Last Post Irukandji  
          Started by HappyTrader76, Yesterday, 04:14 PM
          8 responses
          48 views
          0 likes
          Last Post HappyTrader76  
          Working...
          X