protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
DateTime myDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[1].Day, 8, 30, 0);
int myBarsAgo = GetBar(myDateTime);
if ( Close[myBarsAgo] > Close[0])
{zone =1;}
else if ( Close[myBarsAgo] < Close[0])
{zone =2;}
Plot0.Set(zone);
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Relative price indicator
Collapse
X
-
Relative price indicator
i want to compare the current price to the price of yesterday at a specific time. If the condition is satisfied, i should see 1 or 2 in the strategy analyzer. Seems like im missing something.
Code:Last edited by markus1000; 03-26-2014, 10:49 AM.Tags: None
-
Error on calling 'OnBarUpdate' method for indicator 'GapZoneGold' on bar 0: Bar index needs to be greater/equal 0
Comment
-
Hello Markus1000,
Please ensure that you incorporate a CurrentBar check into your OnBarUpdate() so that your script has enough data before calculating.
example:
if(CurrentBar < myBarsAgo)
return;
The reference sample below will explain in further detail as well -
http://www.ninjatrader.com/support/f...ead.php?t=3170Cal H.NinjaTrader Customer Service
Comment
-
i still get the same message in the console, even after adding adding
if(CurrentBar < myBarsAgo)
return;
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
548 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
548 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment