NexusFi: Find Your Edge


Home Menu

 





Creating your own dynamic bar period


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 
caprica's Avatar
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
Posts: 155 since Jul 2009
Thanks Given: 45
Thanks Received: 115

Until/if NT7 ever gets here, I have been trying to create my own bars with dynamic sizing so my strategy can adjust the size of the bar on-the-fly.

I am talking about a dynamic equivalent to
Add(PeriodType.Volume, xxxxx);

Here is what I have but it is a rough draft and far from perfect. I am looking for suggestions from people who have done the same thing and have it working or know how to make it work.

The idea is once the procedure is written, it will be accessed instead of BarsArray[x]. ie:
old:
CustomCCI(BarsArray[3], CCIperiod, CCIsmooth, CCIpitch)
new:
dynamicbar.Set(DynamicPeriod("Volume", "Median", dynamicvolsize);
CustomCCI(dynamicbar, CCIperiod, CCIsmooth, CCIpitch)

 
Code
                            
protected double DynamicPeriod(string charttypestring bartypeint periodsize)

        {
            
double _retvalue     0;
            
double _tempvalue     0;
            
            try
            {
            
            if (
charttype == "Volume" && bartype == "High")
                {
                
int x 0;
                while ((
Volumes[1][x] + _tempvalue) < periodsize)
                    {
                        
_tempvalue += Volumes[1][x];
                        
x++;
                        
//Print(Time[0] + ": Volume of " + x + " = " + Volumes[1][x]);
                    
}
                
_retvalue MAX(Highs[1], x)[0];
                }
                
            if (
charttype == "Volume" && bartype == "Low")
                {
                
int x 0;
                while ((
Volumes[1][x] + _tempvalue) < periodsize)
                    {
                        
_tempvalue += Volumes[1][x];
                        
x++;
                        
//Print(Time[0] + ": Volume of " + x + " = " + Volumes[1][x]);
                    
}
                
_retvalue MIN(Lows[1], x)[0];
                }
                
            if (
charttype == "Volume" && bartype == "Median")
                {
                
_retvalue = (DynamicPeriod("Volume""High"periodsize) + DynamicPeriod("Volume""Low"periodsize)) / 2;
                }
                
            if (
charttype == "Volume" && bartype == "Time")
                {
                
int x 0;
                while ((
Volumes[1][x] + _tempvalue) < periodsize)
                    {
                        
_tempvalue += Volumes[1][x];
                        
x++;
                    }
                
_retvalue ToTime(Times[1][x]);
                }
                
            }
            catch(
Exception e)
            {
                
Log("Exception " eLogLevel.Error);
            }
            return 
_retvalue;
        } 


"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Thanks Mike. Godspeed.
The Elite Circle
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Datafeed for Atas
Platforms and Indicators
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Afternoon-close session
1 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 thanks
  #2 (permalink)
 
caprica's Avatar
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
Posts: 155 since Jul 2009
Thanks Given: 45
Thanks Received: 115

failed to mention BarsArray[1] in above example is my favored 1-range size Add(PeriodType.Range, 1); method.


"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Started this thread Reply With Quote




Last Updated on July 28, 2009


© 2026 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 - Downloads - Top
no new posts