How to reference and plot same indicator 2x on different data series - futures io
futures io futures trading



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


Discussion in NinjaTrader

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

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

(login for full post details)
  #1 (permalink)
San Diego, CA USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
 
GridKing's Avatar
 
Posts: 3,650 since May 2011
Thanks: 584 given, 881 received

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 futures io Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Short Interest Ratio indicator?
ThinkOrSwim
Cross border fund flows / fx correlations
Treasury Notes and Bonds
Volume Profile Indicator for Ninja Script in NT8
NinjaTrader
Indicators for pair trading MES and M2K
Platforms and Indicators
SimplerOptions
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Battlestations: Show us your trading desks!
137 thanks
Want your NinjaTrader indicator created, free?
32 thanks
Big Mike in Ecuador
30 thanks
Saturday Morning Market Replay!
20 thanks
Selling Options on Futures?
19 thanks
 
(login for full post details)
  #3 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received



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
The following user says Thank You to Fat Tails for this post:
 
(login for full post details)
  #4 (permalink)
San Diego, CA USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
 
GridKing's Avatar
 
Posts: 3,650 since May 2011
Thanks: 584 given, 881 received


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 futures io Trade Journal Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > How to reference and plot same indicator 2x on different data series


Last Updated on July 9, 2012


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts