NexusFi: Find Your Edge


Home Menu

 





Need confirmation of NT code please


Discussion in NinjaTrader

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




 
Search this Thread

Need confirmation of NT code please

  #1 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 485 since Jun 2009
Thanks Given: 232
Thanks Received: 415

Here's some code in an indicator that I am trying to understand (Cycle_Identifier):
============================================
int rnglength = 250;
// pLength is set to 3

double range = 0.0, srange = 0.0;
int j=0;
for (int i=0;i<rnglength;i++) {
if(i>=CurrentBar) break;
j++;
srange = srange + (High[i] - Low[i]);
}
range = srange / j * pLength;
====================================================

1) Looks to me like for each bar, the indicator is recalculation for the last 250 bars, the cumulative bar range (H - L) / 750

Is that right?

2) the code tests to be sure there are at least 250 bars on chart
(if(CurrentBar<rnglength) return; ),
so why is "if(i>=CurrentBar) break;" necessary?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

1) it calculates average range of the last 250 bars x 3;
2) my guess is code blew up when bar < 250
then other code was put in to fix that error but the old code didn't get taken out.

Reply With Quote
Thanked by:
  #3 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 683 since Jun 2009
Thanks Given: 758
Thanks Received: 787



Saroj View Post
Here's some code in an indicator that I am trying to understand (Cycle_Identifier):
============================================
int rnglength = 250;
// pLength is set to 3

double range = 0.0, srange = 0.0;
int j=0;
for (int i=0;i<rnglength;i++) {
if(i>=CurrentBar) break;
j++;
srange = srange + (High[i] - Low[i]);
}
range = srange / j * pLength;
====================================================

1) Looks to me like for each bar, the indicator is recalculation for the last 250 bars, the cumulative bar range (H - L) / 750

Is that right?

2) the code tests to be sure there are at least 250 bars on chart
(if(CurrentBar<rnglength) return; ),
so why is "if(i>=CurrentBar) break;" necessary?

Saroj,

This should not be needed in the NT programming. ( My Opinion!!!)

Are the results the same with it commented out??

On another note, I have a big problem with the " range = " line..

---------------------------------------------------------------

range = srange / j * pLength;

--------------------------------------------------------------


Needs brackets above the multiplier or below the divisor?????

No exception for "j" or "pLength" being equal to zero.


RJay

Reply With Quote
Thanked by:
  #4 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 485 since Jun 2009
Thanks Given: 232
Thanks Received: 415

The formula should be "range = (srange / j) * pLength+.000001;" (which I have changed it to); or simply not allow a value of pLength = 0; it is initialized to '3' but user changeable.

however it strikes me as very inefficient. First off, for a range chart, it will remain virtually constant (esp across 250 bars); secondly, even on a tick, volume or minute bar, could one calculate srange by subtracting the value 250 bars ago and adding in the current value rather than summing 250 values on each bar?

Started this thread Reply With Quote
  #5 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 683 since Jun 2009
Thanks Given: 758
Thanks Received: 787


Saroj View Post
The formula should be "range = (srange / j) * pLength+.000001;" (which I have changed it to); or simply not allow a value of pLength = 0; it is initialized to '3' but user changeable.

however it strikes me as very inefficient. First off, for a range chart, it will remain virtually constant (esp across 250 bars); secondly, even on a tick, volume or minute bar, could one calculate srange by subtracting the value 250 bars ago and adding in the current value rather than summing 250 values on each bar?

Saroj,

Good luck with this!!

I have so much on my plate right now with my volume watch projects.

Maybe someone else could assist.

RJay

Reply With Quote




Last Updated on September 26, 2009


© 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