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 pibrew, Today, 06:37 AM
      0 responses
      4 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      14 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      11 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      16 views
      0 likes
      Last Post AaronKoRn  
      Working...
      X