How can I do that?
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
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.BertrandNinjaTrader Customer Service
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
-
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
-
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 strategist007, Today, 07:51 PM
|
0 responses
2 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by StockTrader88, 03-06-2021, 08:58 AM
|
44 responses
3,968 views
3 likes
|
Last Post
by jhudas88
Today, 06:59 PM
|
||
Started by rbeckmann05, Today, 06:48 PM
|
0 responses
5 views
0 likes
|
Last Post
by rbeckmann05
Today, 06:48 PM
|
||
Started by rhyminkevin, Today, 04:58 PM
|
4 responses
58 views
0 likes
|
Last Post
by dp8282
Today, 06:13 PM
|
||
Started by iceman2018, Today, 05:07 PM
|
0 responses
6 views
0 likes
|
Last Post
by iceman2018
Today, 05:07 PM
|
Comment