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, 04-25-2024, 05:20 AM
      8 responses
      61 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      4 responses
      3,287 views
      1 like
      Last Post jgualdronc  
      Started by Option Whisperer, Today, 09:55 AM
      0 responses
      5 views
      0 likes
      Last Post Option Whisperer  
      Started by halgo_boulder, 04-20-2024, 08:44 AM
      2 responses
      22 views
      0 likes
      Last Post halgo_boulder  
      Started by mishhh, 05-25-2010, 08:54 AM
      19 responses
      6,189 views
      0 likes
      Last Post rene69851  
      Working...
      X