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

DrawText Slope

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

    #16
    Not sure what you mean. I'm happy to help with specific questions but unfortunately won't be able to debug the logic for you.
    LanceNinjaTrader Customer Service

    Comment


      #17
      Originally posted by stockgoblin View Post
      Nice,

      Just tried something simple with the Sample DataSeries Indicator:

      protected override void OnBarUpdate()
      {

      myDataSeries.Set(Math.Abs(Close[0] - Close[1]));

      int i;

      for (i = 0; i < 256; ++i)
      {

      if ((Close[0] - Close[1]) == myDataSeries[i])
      {
      DrawExtendedLine("Slope" + Time, false, 1, Close[1], 0, Close[0], Color.Green, DashStyle.Dash, 2);

      }
      }

      Shouldn't that do something or am I missing a concept as nothing appears and I'm using SVLC Weekly Data which contains 2 sets of parallell slopes.

      Close[0] - Close [1] = .11
      Close[1] - Close [2] = .11

      Close[7] - Close [8] = .08
      Close[12] - Close [13] = .08
      You should see an error in your log about bounds. If you look at your code, you will see that your for loop is trying to access myDataSeries[255], which will only exist if you have at least 256 entries in your myDataseries. Therefore, you either have to modify the for loop to account for less or you have to avoid processing the loop until you have enough bars.

      1. Account for fewer bars:
      Code:
       
      if (CurrentBar < 1) return; //at top of OBU to account for trying to access bars one bar back on the next statement.
      ...
      for (i = 0; i < Math.Min(CurrentBar, 256); ++i) ... //will use the CurrentBar value until there are 256 bars, then use 256.
      2. Avoid processing the loop until you have enough bars:
      Code:
       
      if (CurrentBar < 256) return; //at top of OBU

      Comment


        #18
        Alright! Koganam to the rescue!!

        I got it to work!

        Thanks for your help.

        Live logic & long prosper.
        Last edited by stockgoblin; 03-25-2013, 05:18 PM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,404 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        95 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        7 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        159 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X