NexusFi: Find Your Edge


Home Menu

 





Bars Object as input to Indicator


Discussion in NinjaTrader

Updated
    1. trending_up 4,821 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Bars Object as input to Indicator

  #1 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395

I am looking at creating an Indicator which passes a new Input series for processing.

I have been playing with the Bars object:

 
Code
private Bars newbars;
In the OnBarUpdate:
 
Code
            if (CurrentBar==0)
            {
                newbars = new Bars(Instrument,BarsPeriod,BarsPeriod.Time[0],Time[0],false,false);
             }

            newbars.Add(Open[0],High[0],Low[0],Close[0],Time[0],(long)Volume[0],TickSize,false);
I would then like to be able to pass this new object after modification or addition of more data to an indicator such as:

 
Code
EMA(newbars, 6);
then plot, etc....

For some reason, this doesn't seem to work. This should pretty much pass the current data into a new Bars object and be processed as such through EMA, but it doesn't seem like the newbars object is being updated.

Has anyone worked with the Bars Object like this before?

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
Cheap historycal L1 data for stocks
Stocks and ETFs
Better Renko Gaps
The Elite Circle
 
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


I think your idea is not compatible with the architecture of NinjaTrader. I guess what you want to achieve is use a second bar series and then pass values calculated from that bar series to an indicator.

This can only be achieved, if your new bars are called by OnBarUpdate(). They should also be called in a synchronized way with the first bar series. NInjaTrader will do you this favor, if the secondary bar series needs to be added in the Initialize() section of your indicator:

 
Code
Add(string instrumentName,  PeriodType periodType,  int  period, MarketDataType marketDataType);
Once you have added the bars you can call them from within an indicator, but you cannot apply an EMA to a bars object, but only to a DataSeries object, so you the expression would be
 
Code
EMA(Closes[1],6)[0]
where Closes[1] is the DataSeries construed from the first secondary bars object added.

Now every incoming tick of real-time data will first trigger an update of the main bar series and then an update the secondary bar series.

Reply With Quote
Thanked by:
  #4 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395

Thanks Fat Tails,

I was hoping that may not be the case, but feel you may be correct. There is one setting at the end of the Add function which is a bool for RealTime. I was hoping that would signal somehow to use the passed series... There are several Indicators that use more than a simple DataStream, they us the Bar data Open,Close,High,Low. It would be nice to figure out how to wrap the data such that it can be feed back into these indicators. It would allow fabrication of future data as well as correcting outliers in back data. This might help predict when action needs to take pace a little sooner than when the event has already passed by and you can't get in fast enough (setting market stop limits for example).

I might contact NinjaTrader support to see if they can shed light on if this is possible. I would really like to try a few ideas...

Thanks again,
NJAMC

Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on May 21, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts