Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do you do this?

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

    How do you do this?

    I cannot get this to work, could someone point me in the right direction? I'm simply trying to draw on the 1min chart that the indicator is loaded on when the current 5min close is > close from 1 5min bar ago.


    Code:
    protected override void Initialize()
    {
                Overlay    = false;
                Add(PeriodType.Minute, 5);
    }
    
    protected override void OnBarUpdate()
    {
       if (BarsInProgress == 0)
       {
             if (Closes[1][0] > Closes[1][1])
             {
                   DrawLine("LongLine" + CurrentBars[0], true, 0, 24.5, 0, 24.25, Color.LightGreen, DashStyle.Dash, 1);
              }
         }
    }


    Thanks

    #2
    LookOutBelow,

    Thank you for your post.

    You may want to set the DrawOnPricePanel to false to be able to do this as well.
    In the Initialize() section -
    Code:
    DrawOnPricePanel = false;
    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by lookOutBelow View Post
      I cannot get this to work, could someone point me in the right direction? I'm simply trying to draw on the 1min chart that the indicator is loaded on when the current 5min close is > close from 1 5min bar ago.


      Code:
      protected override void Initialize()
      {
                  Overlay    = false;
                  Add(PeriodType.Minute, 5);
      }
      
      protected override void OnBarUpdate()
      {
         if (BarsInProgress == 0)
         {
               if (Closes[1][0] > Closes[1][1])
               {
                     DrawLine("LongLine" + CurrentBars[0], true, 0, 24.5, 0, 24.25, Color.LightGreen, DashStyle.Dash, 1);
                }
           }
      }
      Thanks
      What is the error in your log?

      Comment


        #4
        Thanks for the response. Unfortunately this does not work. It still will not draw on the chart unless the OnBarUpdate() looks like this:

        Code:
        if (BarsInProgress == 0)
        {
           DrawLine("LongLine" + CurrentBars[0], true, 0, 24.25, 0, 24, Color.Red, DashStyle.Dash, 3 );
        }
        As soon as I put in an IF statement, it doesn't draw.. And yes, the condition is happening.


        Code:
        if (Close[0] > Close[1])
             DrawLine("LongLine" + CurrentBars[0], true, 0, 24.25, 0, 24, Color.Red, DashStyle.Dash, 3 );

        Comment


          #5
          lookOutBelow,

          The reason for this is because there will not be a bar ago, essentially there is not enough data at bar 0 to calculate to look a bar ago.

          The script will start from the far left of the chart at the very beginning where the CurrentBar will equal 0 and then start working to the right, calling each bar for OnBarUpdate();

          What you would nee to do instead is wait for after the first bar to be built from both data series and then run your if check for closes, to ensure that you have enough data.

          Code:
          if(CurrentBars[0] < 1 || CurrentBars[1] < 1) return;
          
          if(Closes[1][0] > Closes[1][1])
          {
               DrawLine();
          }
          Let me know if I can be of further assistance.
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            Thanks Cal.

            I haven't had an opportunity to try this, but will as soon as I can.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X