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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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 | ||
---|---|---|---|---|
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Yesterday, 07:51 PM
|
1 response
12 views
0 likes
|
Last Post Today, 06:59 AM | ||
Started by kaywai, Today, 06:26 AM
|
1 response
6 views
0 likes
|
Last Post
by kaywai
Today, 06:35 AM
|
||
Started by ct, 05-07-2023, 12:31 PM
|
6 responses
205 views
0 likes
|
Last Post
by wisconsinpat
Today, 06:29 AM
|
||
Started by kevinenergy, 02-17-2023, 12:42 PM
|
118 responses
2,780 views
1 like
|
Last Post
by kevinenergy
Today, 05:41 AM
|
||
Started by briansaul, Today, 05:31 AM
|
0 responses
10 views
0 likes
|
Last Post
by briansaul
Today, 05:31 AM
|
Comment