NexusFi: Find Your Edge


Home Menu

 





How to reference and plot same indicator 2x on different data series


Discussion in NinjaTrader

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




 
Search this Thread

How to reference and plot same indicator 2x on different data series

  #1 (permalink)
 
GridKing's Avatar
 GridKing 
San Diego, CA USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 3,630 since May 2011
Thanks Given: 584
Thanks Received: 881

I have added 2 data series and second works and plots fine

I have > bars in progress and bars required

now I would like to add another plot of same

Add(new Plot(Color.Orange, "SMA"));


Add(new Plot(Color.Orange, "SMA")); <<<<<<


and then be able to reference it


if (BarsInProgress == 1)




Value.Set

if (BarsInProgress == 2)

Value.Set <<<<<<<<<<

Could someone please tell me how to do that when you have the time ...

or should I make another indicator all together? Thanks

"Successful trading is one long journey, not a destination" Peter Borish Former Head of Research for Paul Tudor Jones speaking on conversations with John F. Carter
Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Futures True Range Report
The Elite Circle
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 thanks
  #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,102



GridKing View Post
I have added 2 data series and second works and plots fine

I have > bars in progress and bars required

now I would like to add another plot of same

Add(new Plot(Color.Orange, "SMA"));


Add(new Plot(Color.Orange, "SMA")); <<<<<<


and then be able to reference it


if (BarsInProgress == 1)




Value.Set

if (BarsInProgress == 2)

Value.Set <<<<<<<<<<

Could someone please tell me how to do that when you have the time ...

or should I make another indicator all together? Thanks


You can use one indicator. Here are some hints:

(1) please pay attention that the first bar series is BarsInProgress == 0, the second one is BarsInProgress == 1

(2) you need to add two SMAs in the variables section, for example

 
Code
private double firstPeriod // period for first SMA
private double secondPeriod // period for second SMA
private SMA myFirstSMA;
private SMA mySecondSMA;


(3) you also need to add a second bar series in the Initialize() section

(4) in a third step you would define those SMAs in the OnStartUp() section of the indicator

 
Code
myFirstSMA = SMA(Inputs[0], firstPeriod);
mySecondSMA = SMA(Inputs[1], secondPeriod);


Now myFirstSMA will be calculated from the first BarSeries, mySecondSMA from the second Bar Series. You can simply call them in OnBarUpdate(), whenever you like. If you have two PlotSeries, then you can affect values to your PlotSeries, for example

 
Code
if (BarsInProgress == 0)
      Values[0].Set(myFirstSMA[0]);

if (BarsInProgress == 1)
      Values[1].Set(mySecondSMA[0]);

Reply With Quote
Thanked by:
  #4 (permalink)
 
GridKing's Avatar
 GridKing 
San Diego, CA USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 3,630 since May 2011
Thanks Given: 584
Thanks Received: 881


Fat Tails View Post
You can use one indicator. Here are some hints:

(1) please pay attention that the first bar series is BarsInProgress == 0, the second one is BarsInProgress == 1

(2) you need to add two SMAs in the variables section, for example

 
Code
private double firstPeriod // period for first SMA
private double secondPeriod // period for second SMA
private SMA myFirstSMA;
private SMA mySecondSMA;


(3) you also need to add a second bar series in the Initialize() section

(4) in a third step you would define those SMAs in the OnStartUp() section of the indicator

 
Code
myFirstSMA = SMA(Inputs[0], firstPeriod);
mySecondSMA = SMA(Inputs[1], secondPeriod);


Now myFirstSMA will be calculated from the first BarSeries, mySecondSMA from the second Bar Series. You can simply call them in OnBarUpdate(), whenever you like.

Thanks a bunch , the only thing I am a bit confused about is that when the indicator is already named and uses the value as seems to be already coded ... but I copied from the ninja trader example so I guess the calculation in the bottom is the actual code and I can rename it?... Thank You

"Successful trading is one long journey, not a destination" Peter Borish Former Head of Research for Paul Tudor Jones speaking on conversations with John F. Carter
Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on July 9, 2012


© 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