How can I do that?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Using open price variaton to yesterday's close as a parameter
Collapse
X
-
Using open price variaton to yesterday's close as a parameter
I would like to set a variable value to be used on my strategy which value depends on open price to yesterday close (today first price / yesterday last trade price - RHT).
How can I do that?Last edited by dafonseca; 04-19-2013, 06:42 AM.Tags: None
-
One more question..
my strategy uses intrument[0] and [1].
I ve tested and it sometimes is taking PriorClose[0] and PriorClose[1].
I want my strategy (below) to get priorClosePrice of the instrument [1] instead of instrument [0].
How can I get [1] all ways?
protected override void OnBarUpdate()
{
if (Bars.FirstBarOfSession)
{
priorClosePrice = PriorDayOHLC().PriorClose[1];
} ...................
Comment
-
Great!
Now, supposing I do not want to use priorClose all day long, but instead the Medians price [many hours ago].
How it will work in case instrument[1] only trades RHT. if now is 10.30 can I consider the Medians[] would be yesterday price at 12.30??? (considering 5 hours lag)
Do I have to reconsider it when instrument [1] trades EHT, such as ES futures, etc..?
protected override void OnBarUpdate()
{
priorClosePrice2 = Medians[300] (supposing 1 minute bars = 5 hours).
} ..
Comment
-
dafonseca, for the session templates used for your MultiSeries scripts, please keep this in mind -
If a multi-series script adds an additional Bars object that already exists on the chart, the script will use the preexisting series instead of creating a new one to conserve memory. This includes that series' session template as applied from the chart. If the Bars object does not exist on the chart, the session template of the added Bars object will be the session template of the primary Bars object. If the primary Bars object is using the "<Use instrument settings>" session template then the additional Bars objects will use the default session templates as defined for their particular instruments in the Instrument Manager.
The bar index you use would be relative to the series / BarsInProgress context.
Comment
-
Bars.FirstBarUpdate X PriorClose
I need to get yesterday's closing prices for the three instruments which i use on my strategy. Below is part of my code. But the variables are not returning expected values, What am I doing wrong??
protected override void OnBarUpdate()
{
if (BarsInProgress == 0 && Bars.FirstBarOfSession)
{
priorClosePriceAsset = PriorDayOHLC().PriorClose[0];
}
if (BarsInProgress == 1 && Bars.FirstBarOfSession)
{
priorClosePriceVX = PriorDayOHLC().PriorClose[1];
}
if (BarsInProgress == 2 && Bars.FirstBarOfSession)
{
priorClosePriceNQ = PriorDayOHLC().PriorClose[2];
}
Comment
-
You are using BarsInProgress as a filter, so your index should be '0' for all your barSeries.Originally posted by dafonseca View PostI need to get yesterday's closing prices for the three instruments which i use on my strategy. Below is part of my code. But the variables are not returning expected values, What am I doing wrong??
protected override void OnBarUpdate()
{
if (BarsInProgress == 0 && Bars.FirstBarOfSession)
{
priorClosePriceAsset = PriorDayOHLC().PriorClose[0];
}
if (BarsInProgress == 1 && Bars.FirstBarOfSession)
{
priorClosePriceVX = PriorDayOHLC().PriorClose[1];
}
if (BarsInProgress == 2 && Bars.FirstBarOfSession)
{
priorClosePriceNQ = PriorDayOHLC().PriorClose[2];
}
Comment
-
I got it.. It is working know.Originally posted by koganam View PostYou are using BarsInProgress as a filter, so your index should be '0' for all your barSeries.
In case I do not use the filter BarsInProgress , using [0] [1] [2] would work? (and I will get the closing price for all instruments)
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
656 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
371 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 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
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
579 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment