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

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 geddyisodin, Today, 05:20 AM
      5 responses
      32 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by bmartz, Today, 09:30 AM
      2 responses
      12 views
      0 likes
      Last Post bltdavid  
      Started by f.saeidi, Today, 11:02 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by geotrades1, Today, 10:02 AM
      4 responses
      12 views
      0 likes
      Last Post geotrades1  
      Started by rajendrasubedi2023, Today, 09:50 AM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X