Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Any reason why LinRegSlope won't work with CurrentBar?

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

    Any reason why LinRegSlope won't work with CurrentBar?

    Relevant code below. It works when I replace CurrentBar with a static value.. but what I'm really trying to do is calculate the LinRegSlope from the first bar to the latest bar.. in other words..

    Bar0 -> Bar 1
    Bar0 -> Bar 2
    Bar0 -> Bar 3

    I thought by setting the period of the LinRegSlope to the number of the CurrenBar, I'd get this behavior..

    Code:
    		protected override void OnBarUpdate()
    		{
    			if (CurrentBar < 3)
    				return;
    			//Add your custom indicator logic here.
    			double value = LinRegSlope(CurrentBar)[0];
    			Slope[0] = value;
    			Print("The current slope value is " + value.ToString());
                            // this just prints 0
    		}

    #2
    Hello amedhussaini,

    Thank you for your inquiry.

    I am unable to reproduce this on my end.

    Can you please provide an example script that duplicates this behavior so I may test on my end?
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      I'm using NT8, if that helps. I'm attaching the exported NinjaScript here..



      Thanks,
      Amed
      Attached Files

      Comment


        #4
        Hello amedhussaini,


        What happens when you try and load your script from your end?


        We were not successful in testing the code you provided. During our tests it tries to process too much data, and results in crashing the platform.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 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
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X