NexusFi: Find Your Edge


Home Menu

 





Indicator to record H, L, Swing, Range, ZigZag


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one jungian with 2 posts (0 thanks)
    2. looks_two dorschden with 2 posts (5 thanks)
    3. looks_3 Big Mike with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 6,885 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Indicator to record H, L, Swing, Range, ZigZag

  #1 (permalink)
 
jungian's Avatar
 jungian 
Ontario
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus/ZF
Trading: ES, 6E, CL
Posts: 97 since Aug 2009
Thanks Given: 88
Thanks Received: 270

Indicator to record H, L, Swing, Range, ZigZag

I am looking for some help with Ninja re: storing data as variables.

Here is a marked up chart with a legend:

[img]https://nexusfi.com/v/j9j7d8.bmp[/img]

Red Square: Bar lows
Green Squares: Bar highs
Yellow Hash: ZigZag
Salmon Line: Swing High
Green Line: Swing Low
Blue Bars at bottom: Range Calculator.

I need a recorder that stores the information for "X" bars back that will record independently
the variables for all of these:

For example I have 32 bars of data shown in the screenshot.

So I need 32 bars of data with the following information:

For example at bar 3 the information so far recorded would be;

Bar 1: High 1.2381, Low 1.2373, Swing Low 1.2369, Swing High 1.2394, Range: 9
Bar 2: High 1.2383, Low 1.2378, Swing Low 1.2369, Swing High 1.2394, Range: 5
Bar 3: etc etc


So the simplified info
B1, H=1.2381, L=1.2373, SL=1.2369, SH=1.2394, R=9

Any help with this would be much appreciated.

I would like to set it for as many bars back as I need and be able to retreive the variables for calculating.

Any help is much appreciated


Thanks
Jungian

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 dorschden 
Germany
 
Experience: Master
Platform: NinjaTrader
Posts: 112 since Jun 2009
Thanks Given: 59
Thanks Received: 1,143



jungian View Post
Indicator to record H, L, Swing, Range, ZigZag

I am looking for some help with Ninja re: storing data as variables.

I need a recorder that stores the information for "X" bars back that will record independently
the variables for all of these:

Bar 1: High 1.2381, Low 1.2373, Swing Low 1.2369, Swing High 1.2394, Range: 9
Bar 2: High 1.2383, Low 1.2378, Swing Low 1.2369, Swing High 1.2394, Range: 5
Bar 3: etc etc

Hey Jungian,

you can do this for example with a list (or any other data structure depends on the usage) of a struct object that holds all information.

 
Code
                            
private struct BarInformation

{
  public 
int barNumber;
  public 
double highPrice;
  ...

  public 
BarInformation(int numberdouble high, ...)
  {
    
barNumber number;
    
highPrice high;
    ...
  }
}

// A list that holds the BarInformation
private List<BarInformation>  information = new List<BarInformation>();

protected 
override void OnBarUpdate()
{
  
BarInformation info = new BarInformation(CurrentBarHigh[0],...);
  
information.Add(info);
  
// Get the high of a specific bar
  
double highValue information[8].high;

dorschden

Reply With Quote
Thanked by:
  #4 (permalink)
 
jungian's Avatar
 jungian 
Ontario
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus/ZF
Trading: ES, 6E, CL
Posts: 97 since Aug 2009
Thanks Given: 88
Thanks Received: 270

Dorschden....Thanks for your help....

What about storing the Range of each Bar? And the Swing High/Low variable?

How do I 'access' the Range and the Swing High/Low data?

My real question is how do I then go about 'calling' on these variables to be used in calculations?

Sorry but my programming experience is very very limited.

For example if I want to use the stored inputs of the last 'X' number of bars how do I invoke them?

In plain English programming

GET Bar 1 thru 8 lows, GET Swing Low, GET Range of bars 1 thru 8 etc.


Any help would be great.
Jungian

Started this thread Reply With Quote
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,610

Moderator Notice
Moderator Notice



Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 dorschden 
Germany
 
Experience: Master
Platform: NinjaTrader
Posts: 112 since Jun 2009
Thanks Given: 59
Thanks Received: 1,143


jungian View Post
What about storing the Range of each Bar? And the Swing High/Low variable?

How do I 'access' the Range and the Swing High/Low data?

My real question is how do I then go about 'calling' on these variables to be used in calculations?

Sorry but my programming experience is very very limited.

For example if I want to use the stored inputs of the last 'X' number of bars how do I invoke them?

In plain English programming

GET Bar 1 thru 8 lows, GET Swing Low, GET Range of bars 1 thru 8 etc.


Any help would be great.
Jungian

You have to calculate all values you want to store and then create an information object with all this values and add this to your list.

 
Code
                            
protected override void OnBarUpdate() 


  
// Calculate all values
  // Bar number
  
number CurrentBar;
  
// High and low
  
high High[0];
  
low Low[0];
  
// Range of the bar
  
range High[0] - Low[0];

  ... 
For swing values you need another indicator to calculate the swing values (e.g. NT standard swing indicator). I don't know what swing values you want store for each bar, but I think the swing price and the number of bars the swing is ago make sense.

 
Code
                            
// Calculates how many bars back the last swing high occurred

// if -1 no swing high is in this period(=20 bars for example)
int swingHighBarsBack Swing(strength).SwingHighBar(01period);

// No swing high
if (swingHighBarsBack == -1)
  
swingHigh = -1;
// Swing high
else
  
swingHigh Swing(strength).SwingHigh[swingHighBarsBack];

// for swing low vice versa

// Now you have all your calculated values and can store them

// Create a BarInformation object
BarInformation info = new BarInformation(numberhighlowrange,
  
swingHighBarsBackswingHighswingLowBarsBackswingLow); 
// Add this to your list
information.Add(info); 
// Now all your values are stored and you can use them for calculations

// Get the bar range 8 bars ago
double rangeValue information[CurrentBar 8].range;
// Get the swingLow 21 bars ago
double swingLowValue information[CurrentBar 21].swingLow;
// Now you can use rangeValue and swingLowValue in your calculations


// if you want invoke a period of data you can use a loop
// e.g. average of the last 5 bar ranges
// Create a variable that stores the sum of the last 5 ranges
double rangeAverage 0.0;
// a loop
for (int i 15i++)
{
  
// Sum of the values
  
rangeAverage rangeAverage information[CurrentBar i].range;
}
// Range average is the sum divided by 5
rangeAverage rangeAverage 5
The standard call to get your stored information is

information[barsAgo the value you want access for].VALUE is the value you want access for

Hope this helps.

dorschden

Reply With Quote




Last Updated on June 21, 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