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 sjsj2732, 03-23-2026, 04:31 AM
        0 responses
        76 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        313 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        312 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        149 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        112 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X