Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Switching States

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

    Help with Switching States

    Please see the attached doc for details:

    in set 1 I set check if in trade and set variables 1-5 to 0

    in set 2 I set trading time to 800 am to 4pm
    check to see if in a trade
    if variable 1 =0
    the high is greater than or equal to the upper keltner channel
    then
    draw a blue vertical line
    set variable 1 to 1
    set variable 2 to 1

    in set 3 check to see if in trade
    if variable 1 = 1
    the close is less than or equal to the keltner channel midline
    then
    draw a red vertical line
    set variable 1 back to 0

    I would think that this would draw a blue line when conditions were met followed by a red line when the second condition was met. I should see repeating blue/red lines

    Its not drawing the reds and shouldn't draw a clusters of blues. How do I fix this?
    Attached Files

    #2
    Hello,
    Thank you for the question.

    Looking through the images and description I do not see anything apparent as to what might be happening. Without manually recreating everything you have I am unable to see what is happening.

    If you wouldn't mind attaching the strategy file so that I could run it on my end and see what is happening I would be happy to look it over.

    The file its self would be located at \Documents\NinjaTrader 7\bin\Custom\Strategy


    Please let me know if I may be of additional assistance.

    Comment


      #3
      attached strategy

      see attached
      Attached Files

      Comment


        #4
        I am currently working on this in the wizard

        Comment


          #5
          Hello,

          I was able to take a look at the attached strategy.

          It looks like the problem is that variable1 is constantly being set to 0 because you are always flat as there currently is not order logic.
          The strategy does not start a position ever so variable 1 is briefly set as the blue vertical line is plotted then immediately set back to 0.

          If you remove the If variable 1 == 1 from set 3 this script works.

          You will need to provide additional logic for your orders in order to use the Position.MarketPosition as a valid check, otherwise you are always in a flat position.

          Please let me know if I may be of additional assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          672 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