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

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 Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,788 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            837 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,292 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            12 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            62 views
            0 likes
            Last Post halgo_boulder  
            Working...
            X