Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting current month open value in a multi time series indicator when in Historical

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

    Getting current month open value in a multi time series indicator when in Historical

    Hello! I am developing a multi time series indicator that runs on 60 minute time frame and is intended to show current month open value. The indicator runs in OnEachTick mode. How can I get the current month open value when the indicator is in Historical state?

    Calling Opens[1][0] results in previous month open value (since in Historical state indicator runs in OnBarClose mode only and so there is no yet closed/formed bar for the current month).

    Here is my code snippet:

    ...
    else if (State == State.Configure){
    AddDataSeries(BarsPeriodType.Month,1);
    }
    ...
    protected override void OnBarUpdate(){
    if (CurrentBars[1] < 0) return;

    if (BarsInProgress == 0){
    double open = Opens[1][0];
    Print(open.ToString());
    }
    }

    #2
    Hello akuntysh,

    Thank you for your note.

    The code below will print the current months open, in real time as well as historically.

    Code:
    else if (State == State.Configure)
    {
    	AddDataSeries(BarsPeriodType.Month,1);
    }

    Code:
    protected override void OnBarUpdate()
    {[INDENT]if(CurrentBars[1]<1) return;[/INDENT]
    			
    [INDENT]if (BarsInProgress == 1)
    {
    	double open =  Bars.GetOpen(BarsArray[1].Count-1);
    	Print(open.ToString());
    
    }[/INDENT]
    }


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you Alan! This is exactly what I was looking for!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X