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 andrewtrades, Today, 04:57 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      3 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X