Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need Help with plotting line at the open price on the hour

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

    Need Help with plotting line at the open price on the hour

    Below is my attempt at coding what I am asking for but has compilation errors. Can you help?



    {
    if (CurrentBar < 24) return;
    int H1 = 0;
    for (int barsAgo = 0; barsAgo < 24; barsAgo++)
    {
    H1 = H1 + Input[barsAgo];
    }
    if (ToTime(Time[0]) >= ToTime(H1, 00, 00))
    {
    int bartime = CurrentBar - Bars.GetBar(new DateTime(2007,1,16,H1,0,0));
    }
    DrawHorizontalLine("Hour Open",Open[bartime],Color.Blue);
    }

    #2
    H1 = H1 + Input[barsAgo];
    That will cause some problems since Input[barsAgo] is a double while H1 is an int. If you changed H1 to a double you will still have problems over here:
    ToTime(H1, 00, 00)
    The inputs for ToTime() should be ints not doubles. I am also not sure if you can use an int > 24 for the input of your DateTime variables. Your H1 variable can surely take on a value greater than 24 and cause problems in that aspect too.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh. Got the following to compile but still not updating my line on the hour. Any thoughts.

      --------------------------------------------------
      -------------------------------------------------

      protected override void OnBarUpdate()
      {
      //if (CurrentBar < 24) return;
      int H1 = 0;
      for (int barsAgo = 0; barsAgo < 24; barsAgo++)
      {
      H1 = H1 + barsAgo;
      }
      if (ToTime(Time[0]) - H1*10000 < 0)
      {
      int bartime = CurrentBar - Bars.GetBar(new DateTime(2008,1,17,0,0,0));

      DrawHorizontalLine("Hour Open",Open[bartime],Color.Blue);
      DrawVerticalLine("Hour Line",bartime,Color.Blue);

      }
      else
      if (ToTime(Time[0]) - H1*10000 >= 0)
      {
      int bartime = CurrentBar - Bars.GetBar(new DateTime(2008,1,17,H1,0,0));

      DrawHorizontalLine("Hour Open",Open[bartime],Color.Blue);
      DrawVerticalLine("Hour Line2",bartime,Color.Blue);


      }

      -----------------------------------------------------------
      --------------------------------------------------------

      Comment


        #4
        You will need to debug your code. Please check out this tip: http://www.ninjatrader-support.com/v...ead.php?t=3418

        If you look in the Log tab in the Control Center you will see an error to this effect:
        Code:
        Error on calling the 'OnBarUpdate' method for indicator 'drawtest' on bar 0: drawtest.DrawVerticalLine: bar must be greater/equal 0 but was -251
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks for pointing this out. Still working on it will. See what you get if you delete the "DrawHorizontaLine" line of code.

          Comment


            #6
            Due to bandwidth issues I cannot help you debug your code. Thanks for understanding. I suggest you us Print functions on your H1 values and your bartime values in the manner recommended in the tip I provided you.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by WHICKED, Today, 09:05 PM
            0 responses
            9 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by luislag14, Today, 06:29 PM
            0 responses
            8 views
            0 likes
            Last Post luislag14  
            Started by Protech, Today, 11:08 AM
            1 response
            23 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by guilhem, Today, 02:09 PM
            1 response
            24 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by Hyper, Today, 12:20 PM
            1 response
            23 views
            0 likes
            Last Post NinjaTrader_Jim  
            Working...
            X