Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Custom indicator
Collapse
X
-
Hi U0000999, thanks for your question.
The general logic in OnBarUpdate would go something like this:
Code:int period = 20; protected override void OnBarUpdate() { if(CurrentBars[0] < period) return; double sum = 0; for(int i = 0; i < period; i++) { sum += High[i] - Low[i] / 2; } Print(sum); }
Please let me know if I can assist any further.Chris L.NinjaTrader Customer Service
-
Hi Chris,
Congrats to your post no. 3000 :-) .
I just added the average and some prints.
int period = 20;
protected override void OnBarUpdate()
{
if(CurrentBars[0] < period) return;
double sum = 0;
double average = 0;
for(int i = 0; i < period; i++)
{
sum += High[i] - Low[i] / 2;
average = sum / (i+1);
}
Print("Sum: " + sum.ToString("N2"));
Print ("Period: " + period.ToString());
Print("Average: " + average.ToString("N2"));
}
Thx.
NT-Roland
- Likes 1
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by DJ888, Today, 10:57 PM
|
0 responses
1 view
0 likes
|
Last Post
by DJ888
Today, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
158 views
0 likes
|
Last Post Today, 10:23 PM | ||
Started by Belfortbucks, Today, 09:29 PM
|
0 responses
7 views
0 likes
|
Last Post
by Belfortbucks
Today, 09:29 PM
|
||
Started by zstheorist, Today, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
151 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
Comment