Help - how can I use Dataseries wich are calulate by an other Indicator? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Help - how can I use Dataseries wich are calulate by an other Indicator?
Updated: Views / Replies:2,941 / 12
Created: by Trendseek Attachments:5

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 5  
 
Thread Tools Search this Thread
 

Help - how can I use Dataseries wich are calulate by an other Indicator?

  #1 (permalink)
Elite Member
Leipzig / Germany
 
Futures Experience: Intermediate
Platform: NT / TS, MC and Clones
Broker/Data: Interactive Broker
Favorite Futures: Futures, Forex
 
Posts: 24 since Aug 2009
Thanks: 31 given, 34 received

Help - how can I use Dataseries wich are calulate by an other Indicator?

Hello Ninjas,
just a simple C#-Question...

I try to develope an Indicator for a Bollinger-Band, based on a "faster" Moving Average.
To calculate the Standard-Deviation for that "faster" MA (i.e. EMA or HMA), I have the Idea, to customize the normal StdDev Indicator, so, that it is able to use that "faster" MA from the calling Bollinger-Band Indicator without a recalculation - the "faster" MA must be "visible" for the new StdDev-Indicator.

Here is my Question - How can I make the "faster" MA, calculate in the new faster Bollinger-Band Indicator, visible in the customized StdDev?

Within the "FastBollinger" I call that customized StdDev as followed:

 
Code
//Calculate the fast MA
fastMA.Set(EMA(Period)[0]);

//Calling the customized StdDev with the fastMA
double StdDev = StdDevIND(fastMA, Period)[0];
Unfortunaly the Code for the customized StdDev did not work - It is not able to use the MA-Datastream

 
Code
public class StdDevIND : Indicator
    {
        #region Variables
         // this seeems to be wrong ore incomplete for using the former calulate fast MA
            IDataSeries     IndSeries;

            private int        period    = 14;
        
        #endregion

        protected override void Initialize()
        {
            Add(new Plot(Color.Green, "StdDev"));
//           Perhaps I have to build an Instanz for the MA-Datastream here?
        }

        protected override void OnBarUpdate()
        {
            if (CurrentBar < period)return;            
            else
            {
                double sum = 0;
                  for (int count = 0; count < Period ; count++)
                {
                    double diff = Math.Abs(Input[count] - IndSeries[count]);
                    sum += diff * diff;
                }   

                Value.Set(Math.Sqrt(sum / Period));
            }
        }
Hope, that someone of you can help - so that i can finished that Idea and make it usable for other users!

regards
Trendseek

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,652 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


From your post it is not very clear, what you want to achieve.

1. I understand that you want to calculate a band around a moving average. You are talking about a faster moving average. So there must be a slow one as well that you are not mentioning. Can you tell me what is the purpose of the fast and the slow moving average?

2. You are mentioning different types of moving averages, EMA or HMA. Have you made up your mind, which one to use?

3. What is the mathematical formula for your band?

Reply With Quote
 
  #4 (permalink)
Elite Member
Leipzig / Germany
 
Futures Experience: Intermediate
Platform: NT / TS, MC and Clones
Broker/Data: Interactive Broker
Favorite Futures: Futures, Forex
 
Posts: 24 since Aug 2009
Thanks: 31 given, 34 received

Thanks for reading my Question - and sorry, if my explanation was a unclear.

The normal NT - Bollinger Indicator is based on a Simple Moving Average. The Code is very simple:
Firstly it calculates the SMA, secondly it is calling the Standard Deviation- Indicator with the same Period for calculating the Standard Deviation of that SMA. Thirdly it calculates the two BollingerBands.

Here is the Main-Code Snip for Bollinger
 
Code
            double smaValue    = SMA(Period)[0];
            double stdDevValue = StdDev(Period)[0];
            Upper.Set(smaValue + NumStdDev * stdDevValue);
            Middle.Set(smaValue);
            Lower.Set(smaValue - NumStdDev * stdDevValue);
And this one is the main Code Snip for the StdDev:
 
Code
                sumSeries.Set(Input[0] + sumSeries[1] - (CurrentBar >= Period ? Input[Period] : 0));
                double avg = sumSeries[0] / Math.Min(CurrentBar + 1, Period);
                double sum = 0;
                for (int barsBack = Math.Min(CurrentBar, Period - 1); barsBack >= 0; barsBack--)
                    sum += (Input[barsBack] - avg) * (Input[barsBack] - avg);

                Value.Set(Math.Sqrt(sum / Math.Min(CurrentBar + 1, Period)));
OK - You can see that the called StdDev also calculates a Simple Moving Average (SMA) instead of using the SMA Dataseries from the calling Bollinger Method.

My Intention is to write a modified StdDev Indicator that have access to the Moving Average which was calculated in the calling Method (for example a modified Bollinger-Indicator). This has two Advantages. Firstly it saves Ressources, if you are using complex Moving Averages instead of a simple SMA, and secondly this modified StdDev will be more flexible because you can use it with different Datastreams (mostly different Moving Averages).


Here is my Code Idea for a modified Bollinger (in this example with a "faster" EMA instead of a "slow" SMA).
 
Code
            smaSeries.Set(SMA(Period)[0]);
            double stdDevValue = modifiedStdDev(smaSeries, Period)[0];
            Upper.Set(smaValue + NumStdDev * stdDevValue);
            Middle.Set(smaValue);
            Lower.Set(smaValue - NumStdDev * stdDevValue);
Unfortunaly I have no Idea how to make the smaSeries from that modified Bolinger usable within the modified StdDev - and this is my Question.


Here is my - not working - Code-Idea for the modifiedStdDev
 
Code
public class StdDevIND : Indicator
    {
        #region Variables
           // this is for the Moving-Average DataSeries from the calling Method (for example a modified Bollinger)
            IDataSeries     IndSeries;
            private int        period    = 14;
        
        #endregion

        protected override void Initialize()
        {
            Add(new Plot(Color.Green, "StdDev"));
            // Shoud I initialize a new DataSeries for the Moving Average from the calling Method?
        }

        protected override void OnBarUpdate()
        {
            if (CurrentBar < period)return;            
            else
            {
                double sum = 0;
                  for (int count = 0; count < Period ; count++)
                {
                    double diff = Math.Abs(Input[count] - IndSeries[count]);
                    sum += diff * diff;
                }   

                Value.Set(Math.Sqrt(sum / Period));
            }
        }

        #region Properties
        // May I should do something here?
        //public IDataSeries INDSeries
        {
            get { return IndSeries; }
            set { IndSeries = value; }
        }
        
        public int Period
        {
            get { return period; }
            set { period = Math.Max(1, value); }
        }
        #endregion
OK - I hope, that this explanation will be a little bit clearer.
Thanks for reading - and I hope someone can help!

Regards
Trendseek


Last edited by Trendseek; August 31st, 2010 at 10:46 AM.
Reply With Quote
 
  #5 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,652 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary

Maybe this helps


Trendseek View Post
The normal NT - Bollinger Indicator is based on a Simple Moving Average. The Code is very simple:
Firstly it calculates the SMA, secondly it is calling the Standard Deviation- Indicator with the same Period for calculating the Standard Deviation of that SMA

Edit: Text removed. Trendseek is correct. The StdDev indicator uses a simple moving average. So at least I have learned something!

You could try the following code for NT 7(not tested):

 
Code
 
# region Variables
 
private double period = 14;
private double bandperiod = 14;
private double numStdDev = 2.0;
private StdDev StdDev_IND;
private DataSeries MMA_IND;
 
protected override void Initialize()
{
  Add(new Plot(new Pen(Color.Red, 1), PlotStyle.Line, "Middle"));
  Add(new Plot(new Pen(Color.Orange, 1), PlotStyle.Line, "Upper"));
  Add(new Plot(new Pen(Color.Orange, 1), PlotStyle.Line, "Lower"));
   MMA_IND = new DataSeries(this);
     StdDev_IND = new DataSeries(this); 
}
 
protected override void OnStartUp()
{
     MMA_IND = EMA(Input, period);  // you can also replace this with a SMA, HMA or whatsoever
     StdDevInd=StdDev(MMA_IND, bandperiod));  /you can use a different bandperiod
}
 
protected override void OnBarUpdate()
{
   if (CurrentBar < period + bandperiod)}
       return;
   double average = MMA_IND[0];
   double stdDevValue = StdDev_IND[0];
     Middle.Set(average);
     Upper.Set(average + numStdDev * stdDevValue);
     Lower.Set(average - numStdDev * stdDevValue);
}
 
#region Properties
 
etc.


Last edited by Fat Tails; August 31st, 2010 at 02:36 PM. Reason: bug removed
Reply With Quote
 
  #6 (permalink)
Elite Member
Leipzig / Germany
 
Futures Experience: Intermediate
Platform: NT / TS, MC and Clones
Broker/Data: Interactive Broker
Favorite Futures: Futures, Forex
 
Posts: 24 since Aug 2009
Thanks: 31 given, 34 received


Fat Tails View Post
The standard deviation in the Bollinger Band is not calculated for the SMA, but for the original data points. So it does not depend on the type of SMA you choose.

Hello Fat Tails,
thanks again for your answer - but perhaps we use different conceptions about Bollinger, or I simply missconceive you?

Bollinger in his own words: "For Bollinger Bands the measure of central tendency is a simple moving average, and the interval is delineated by a measure of volatility, a moving standard deviation." (Bollinger, John; Bollinger on Bollinger Bands; 2002; S.50). And this is, what we see in the Standard-NT Code above. Do you have some Sources for your interpretation about "centerpoints" and prices?

In my view you need something like the SMA for calculate the Standard Deviation (the Difference between Datapoints and the SMA-Values). By the way - later in his Book, Bollinger discuss the uselessness of "fast Bollinger-Bands" who based on an EMA instead of a SMA for calculate the Standarddeviation.
But back to my SIMPLE MAIN-Question - How can I use a Dataseries in an Indicator like a custumized StandardDeviation which was calculate by an other Indicator (or Method)?

Reply With Quote
The following user says Thank You to Trendseek for this post:
 
  #7 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,652 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


Trendseek View Post
Hello Fat Tails,
thanks again for your answer - but perhaps we use different conceptions about Bollinger, or I simply missconceive you?

Bollinger in his own words: "For Bollinger Bands the measure of central tendency is a simple moving average, and the interval is delineated by a measure of volatility, a moving standard deviation." (Bollinger, John; Bollinger on Bollinger Bands; 2002; S.50). And this is, what we see in the Standard-NT Code above. Do you have some Sources for your interpretation about "centerpoints" and prices?

In my view you need something like the SMA for calculate the Standard Deviation (the Difference between Datapoints and the SMA-Values). By the way - later in his Book, Bollinger discuss the uselessness of "fast Bollinger-Bands" who based on an EMA instead of a SMA for calculate the Standarddeviation.
But back to my SIMPLE MAIN-Question - How can I use a Dataseries in an Indicator like a custumized StandardDeviation which was calculate by an other Indicator (or Method)?


There is no problem with your use of INDSeries. You just need to affect a value to it such as IndSeries = EMA(Input,period);

Maybe you want to use an enum. Could then select via indicator panel, which method you want to use to calculate your moving average.

 
Code
 
#region Global Enums
 
public enum movingAverageType (SMA, EMA, HMA, TEMA, WMA)  // all types of moving averages
 
#endregion
 
#region Variables
 
private movingAverageType  sdAverageType  =  movingAverageType.SMA;
private DataSeries StdDev_IND
 
#endregion
 
....
 
protected override void OnBarUpdate()
{
    ....
   if (sdaverageType == movingAverageType.SMA)
    {
         // insert formula for StdDev_IND calculated from SMA
    }
 
    else if (sdaverageType == movingAverageType.EMA)
    {
        //insert formula for StdDev_IND calculated from EMA
    }
 
.... 
}
 
#region Properties
 
...
 
[Description("Moving Average Type")]
[GridCategory("Parameters")]
[Gui.Design.DisplayNameAttribute("MA Type")]
public movingAverageType SdAverageType
{
get { return sdAverageType; }
set { sdAverageType = value; }
}
 
...


Last edited by Fat Tails; August 31st, 2010 at 02:14 PM.
Reply With Quote
 
  #8 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,652 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary

Universal Bollinger Indicator

Here is a sample of a universal Bollinger Band indicator. It can plot Bollinger bands using 11 different moving averages to be selected via indicator panel.

Took me some time to understand, what you wanted. Hope that this comes close.

Attached Files
Register to download File Type: zip BollingerUniversal.zip (23.1 KB, 26 views)

Last edited by Fat Tails; August 31st, 2010 at 06:29 PM.
Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #9 (permalink)
Elite Member
Santa Clara, CA
 
Futures Experience: Intermediate
Platform: NT, TS
Broker/Data: TS
Favorite Futures: Guitar, but sax is cool too
 
Posts: 18 since Jul 2010
Thanks: 13 given, 16 received


Fat Tails View Post
The StdDev indicator uses a simple moving average. So at least I have learned something!


Ummm, standard deviation is variation around an AVERAGE. It has to use an SMA. If you modify it using anything not an average, it becomes something other than stddev. The multi-MA tool above seems to be the best approach
to me. Play around with different moving averages with Bollinger bands added and subtracted (plus/minus stddev) and I'm sure what you have conceptualized will be in there. But keep in mind that its still the average of the fast moving average for the (period) bars that the standard deviation is being calculated from. The Dataseries is an average of the EMA (for example).

To understand this better, try adding "close" as the dataseries of the stddev to regular Bollinger bands and then you would see the volatility of each bar close (price action). It is just interesting - maybe not useful tho.

G&M

Reply With Quote
 
  #10 (permalink)
Elite Member
Leipzig / Germany
 
Futures Experience: Intermediate
Platform: NT / TS, MC and Clones
Broker/Data: Interactive Broker
Favorite Futures: Futures, Forex
 
Posts: 24 since Aug 2009
Thanks: 31 given, 34 received



gunsnmoney View Post
Ummm, standard deviation is variation around an AVERAGE. It has to use an SMA. If you modify it using anything not an average, it becomes something other than stddev.

The StdDev simple means what it says: It is a standardised deviation (or difference) between two Datasets - nothing else. Instead of an Average you can use a Regression-Line or anything else you want - but you are right: the "original" mathematical notation contains the differences between Datapoints and tha SMA of that Datapoints over a given Period.

@Fat Tails: Wow - a big thanks for your effort - this is a comfortable way to check out and compare different MA-Versions of Bollinger-Bands.
Unfortunaly it did not answers my Question about visibility and the access of different (MA-)Dataseries when they are a public or private.

Greetings from Leipzig
Trendseek


Last edited by Trendseek; September 1st, 2010 at 10:53 AM.
Reply With Quote

Reply



futures io > > > > > Help - how can I use Dataseries wich are calulate by an other Indicator?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple dataseries Breakout NinjaTrader 28 March 30th, 2015 01:14 PM
How to Export DataSeries from NT to Excel? Fat Tails NinjaTrader Programming 65 April 28th, 2014 12:05 PM
Need help with order entry on multiple dataseries bobbakerr EasyLanguage Programming 20 August 29th, 2010 10:03 AM
Redeclaring a dataseries to use as a trailing stop Davidnmfarrell NinjaTrader Programming 5 April 26th, 2010 01:54 PM
catching dataseries from DoubleMA max-td NinjaTrader Programming 1 June 12th, 2009 07:56 AM


All times are GMT -4. The time now is 10:49 AM.

Copyright © 2017 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
Page generated 2017-12-13 in 0.16 seconds with 20 queries on phoenix via your IP 54.227.51.103