Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coding Question

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

    Coding Question

    If after a ma crossover, I have coded that I want to put an Up arrow at the first pullback trigger that meets the criteria and then not allow any arrows on the subsequent pullback triggers (that can occur sometimes while still in a trending trade) until the exit criteria has been met. After the exit criteria has been met then the strategy would reset and look for the next crossover and then the first pullback.

    So how do I not allow any other trigger arrows to form between the first trigger arrow that formed and the exit trigger? If that makes sense.

    Thanks

    #2
    Create yourself a flag variable. Set this flag variable to true when you draw your first up arrow. Add a condition to your routine that says if this flag variable is true do not draw. Reset the flag variable to false after you have exited.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      i would use a bool flag.

      set it when 1st trigger is set

      check it for every other trigger

      and clear it when exit criteria met

      Comment


        #4
        Thanks for your quick responses.
        Can anyone point me in the right direction to learn how to code the bool flag variable.

        Thanks

        Comment


          #5
          dwalls,

          You can create it like any other variable. In variables region of your code:
          Code:
          private bool flag = false;
          Now anywhere you need the flag just do something like:
          Code:
          if (!flag)
               // Do something when the flag bool is false;
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          670 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X