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

Incorrect Syntax; Execution Ignored?

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

    Incorrect Syntax; Execution Ignored?

    Base Logic:

    if
    // All Variables Reset
    (BarsSinceExitExecution(0, "", 0) == 0)
    {
    EvalHold = false;
    Bar1Long = false;
    Bar2Long = false;
    Bar1Short = false;
    Bar2Short = false;
    }


    I suspect I've written the Bars Since Exit Execution incorrectly. These orders appear to be being ignored.

    Variables which were set to true prior to condition entry can stay that way through the trade and are then supposed to reset to false immediately upon trade completion...

    Lets say a long just successfully completed​...

    if
    // All Variables Reset
    (BarsSinceExitExecution(0, "Long", 0) == 0)
    {
    EvalHold = false;
    Bar1Long = false;
    Bar2Long = false;
    Bar1Short = false;
    Bar2Short = false;
    }




    I want variables to reset to false immediately so to properly wait for 2 variable conditions to become true AFTER the trade completed. What's happening is the conditions for variable one and 2 appear to be using evaluations from inside the active trade and if met are immediately firing on next bar after trade completion. The reset logic employed here appears to be ignored...

    Que Pasa??

    #2
    Hello johnMoss,

    The position will take time to change, so it would be on the next update of OnBarUpdate() where BarsSinceExitExecution() will return the number of bars since the last execution.

    Just to confirm, you are trying to reset these values when the exit order fills and not the entry, is this correct?
    The exit order signal name is "Long" is this correct?

    You could choose to immediately reset these variables at the time the execution fills from OnExecutionUpdate().
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea,

      Yes, The objective is to reset the variables when the trade exit order fills, i.e same bar. Idea is that conditional evaluation to set variables to true as may occur should not restart until the last trade is finished. I gather my logic is error or am missing something?
      Last edited by johnMoss; 11-16-2023, 12:32 PM.

      Comment


        #4
        Hi Chelsea,
        this question still stands... Where/How do I apply the OnExecution Update?: Help guide is not specific...

        Comment


          #5
          Hello johnMoss,

          The OnExecutionUpdate() override must be declared in the scope of the class (between the curly braces for the class) and can only be declared once.

          Below is a link to a reference sample that implements the OnExecutionUpdate() override.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X