NexusFi: Find Your Edge


Home Menu

 





Normalizing output from Indicators


Discussion in NinjaTrader

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




 
Search this Thread

Normalizing output from Indicators

  #1 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184

Greetings! AND Happy Thanksgiving Day to those celebrating!! Hope you had a wonderful time!!!!

I ran into set of errors in a strategy I was building, and narrowed down the issue to two small sections of code.

The sections are both in the 'short' side of the strategy, and because the indicator generating the code (Empirical Mode Decomposition) has lots of decimals in the output (using ForEx), I modified in the code to compensate, so now I have a more workable (roughly) range of +300 to -300 ... but still have the ' object reference not set to an instance of an object.' when I run the strategy. I am 99.44% sure it is not in the strategy code itself because the same components & calculations are in other lines that work without any problems, and a change as simple as changing '<' to '>' cures the problem, but changes the strategy results

What I would like to accomplish is to 'normalize the data output from the indicator, to have all positive values, without changing the waveform that is currently being produced. I did a bit of google on this, but I cant understand the math involved ... so I am looking for a small assist from somebody more clever :sos:

the .cs of the modified indicator is attached ... it does compile as is in NT7rc1 and charts fine .. the code section that needs modification is
 
Code
                            
     protected override void OnBarUpdate()

        {
            if (
CurrentBar == 0)
            {
                
beta Math.Cos(Math.PI Period);
                
gamma Math.Cos(Math.PI Delta Period);
                
alpha gamma Math.Sqrt(Math.Pow(gamma2) - 1);
            }
            
            if (
CurrentBar 51)
            {
                
BP.Set(0);
                
Peak.Set(0);
                
Valley.Set(0);
                return;
            }

            
BP.Set(0.5 * (alpha) * ((((High[0] + Low[0]) / 2) - ((High[2] + Low[2]) / 2))*1000000) + beta * (alpha) * BP[1] - alpha BP[2]);
            
            
mean jhlEMA(BP2*Period)[0];
            
            
Peak.Set(Peak[1]);
            
Valley.Set(Valley[1]);
            
            if (
BP[1] > BP[0] && BP[1] > BP[2])
                
Peak.Set(BP[1]);
            if (
BP[1] < BP[0] && BP[1] < BP[2])
                
Valley.Set(BP[1]);
            
            
avgPeak jhlEMA(Peak50)[0];
            
avgValley jhlEMA(Valley50)[0];
            
            
UpperBand.Set(avgPeak Fraction);
            
LowerBand.Set(avgValley Fraction);
            
MainPlot.Set(mean);
            
MidLine.Set(((avgPeak Fraction) + (avgValley Fraction))/2);
        } 
the BT.Set calculation is the one that needs to be tamed

Any additional input is always welcome!
TJ

Attached Files
Elite Membership required to download: EMDT.cs
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #3 (permalink)
 
eDanny's Avatar
 eDanny 
East Rochester, NY
 
Experience: Intermediate
Platform: NT
Posts: 329 since Jul 2009
Thanks Given: 18
Thanks Received: 425



Trader.Jon View Post
Greetings! AND Happy Thanksgiving Day to those celebrating!! Hope you had a wonderful time!!!!

I ran into set of errors in a strategy I was building, and narrowed down the issue to two small sections of code.

The sections are both in the 'short' side of the strategy, and because the indicator generating the code (Empirical Mode Decomposition) has lots of decimals in the output (using ForEx), I modified in the code to compensate, so now I have a more workable (roughly) range of +300 to -300 ... but still have the ' object reference not set to an instance of an object.' when I run the strategy. I am 99.44% sure it is not in the strategy code itself because the same components & calculations are in other lines that work without any problems, and a change as simple as changing '<' to '>' cures the problem, but changes the strategy results

What I would like to accomplish is to 'normalize the data output from the indicator, to have all positive values, without changing the waveform that is currently being produced. I did a bit of google on this, but I cant understand the math involved ... so I am looking for a small assist from somebody more clever :sos:

the .cs of the modified indicator is attached ... it does compile as is in NT7rc1 and charts fine .. the code section that needs modification is
 
Code
                            
     protected override void OnBarUpdate()
        {
            if (
CurrentBar == 0)
            {
                
beta Math.Cos(Math.PI Period);
                
gamma Math.Cos(Math.PI Delta Period);
                
alpha gamma Math.Sqrt(Math.Pow(gamma2) - 1);
            }
            
            if (
CurrentBar 2)return; //<=====

           // if (CurrentBar < 51)
           // {
            //    BP.Set(0);
            //    Peak.Set(0);
             //   Valley.Set(0);
             //   return;
             //}

            
BP.Set(0.5 * (alpha) * ((((High[0] + Low[0]) / 2) - ((High[2] + Low[2]) / 2))*1000000) + beta * (alpha) * BP[1] - alpha BP[2]);
            
            
mean jhlEMA(BP2*Period)[0];
            
            
Peak.Set(Peak[1]);
            
Valley.Set(Valley[1]);
            
            if (
BP[1] > BP[0] && BP[1] > BP[2])
                
Peak.Set(BP[1]);
            if (
BP[1] < BP[0] && BP[1] < BP[2])
                
Valley.Set(BP[1]);
            
            if (
CurrentBar 50)return;  //<====

            
avgPeak jhlEMA(Peak50)[0];
            
avgValley jhlEMA(Valley50)[0];
            
            
UpperBand.Set(avgPeak Fraction);
            
LowerBand.Set(avgValley Fraction);
            
MainPlot.Set(mean);
            
MidLine.Set(((avgPeak Fraction) + (avgValley Fraction))/2);
        } 
the BT.Set calculation is the one that needs to be tamed

Any additional input is always welcome!
TJ

I don't know about your original problem but if you make the above changes to the indicator it will be accurate from the beginning of the plots.

Dan

Reply With Quote
Thanked by:




Last Updated on November 27, 2010


© 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