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
Dataseries Array Comparison I Need Help!
Collapse
X
-
Hello NewCode,
It appears you have called EntryLow without an index (a pair of empty brackets). This will not compile.
Which historical bar did you want?
Use the barsAgo value for that bar.
( don't feel that a data series is the correct object here)
-
I have run the code you have shown and am still getting compiler errors. I have also added the SMA portion as you mentioned and am not sure how to call on the current SMA value and compare it to the set 301 or EntryLow value.
public class ArrayTrade : Strategy
{
private DataSeries EntryLow;
protected override void Initialize()
{
EntryLow= new DataSeries(this);
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if(ToTime(Time[0]) == ToTime(3,01,0))
{
EntryLow.Set(Low[0]);
Print(EntryLow[0]);
}
if (DefaultInput[0] + EMA(14)[0] + Low[0] * TickSize < EntryLow[])
{
DrawHorizontalLine("My horizontal line" + CurrentBar, 5, Color.Chartreuse);
}
}
Leave a comment:
-
Hello NewCode,
A dataseries will hold a value for every bar on the chart, so that its possible to access data historically. For example if you wanted to store custom calculated values so that this can be used as the input series for an indicator call like the SMA.
In your code, you seem to only be wanting the current bars value and not any previous bars, is this correct?
If so, you may not be wanting to use a data series.
An array would hold several values, but would not be synced with the bars on the chart. This means if you wanted to store a handful of values you wanted to be able to call at any time, any array would be suitable for this.
If you are only wanting a value for the current bar to store the low or your custom value, a double would be suitable for this.
Further, with the code:
private DataSeries[]EntryLow;
This would be attempting to create an array of dataseries. I would recommend against this.
For a single series
Code:private DataSeries EntryLow; protected override void Initialize() { EntryLow = new DataSeries(this); } protected override void OnBarUpdate() { EntryLow.Set(Low[0]); Print(EntryLow[0]); }
Leave a comment:
-
Dataseries Array Comparison I Need Help!
NinjaTrader 7 Help
I am attempting to utilize 2 DataSeries to compare my current candles Low to the low of a specific time
of day. If the current candles low does indeed show that it is lower, then i check to see if the candle
close is less than the lower Bollinger band. I am confused with how to look back at a particular time within the second array to get the low of the particular set time i have stored. Can anyone help?
In one array i am setting the low of say Time 3:01 and the array length is one since it only needs to keep one Value. The other DataSeries would keep multiple values and check against the shorter
array. As time advances i will check back to 301 again and again until it is time to reset 301 for the next day.
private DataSeries[]EntryLow; // Short Array
private DataSeries myDataSeries; // Long Array
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
EntryLow = new DataSeries[1];// Array Size
//EntryLow = new DataSeries(this);
myDataSeries = new DataSeries(this, MaximumBarsLookBack.Infinite);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
myDataSeries.Set(Low[0]);
if(ToTime(Time[0]) == ToTime(3,01,0))
{
EntryLow.Set(Low[0]);
}
if(ToTime(Time[0]) > ToTime(3,01,0)
&& myDataSeries[0] < EntryLow [0] //Not sure how to call EntryLow stored value
&& Low[0] < Bollinger(2, 14).Lower[0])
{
DrawHorizontalLine("My horizontal line" + CurrentBar, 5, Color.Chartreuse);
}
}Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, Yesterday, 06:40 PM
|
2 responses
19 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
20 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
180 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Leave a comment: