• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dataseries Array Comparison I Need Help!

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • NewCode
    started a topic Dataseries Array Comparison I Need Help!

    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);
    }
    }

  • NinjaTrader_ChelseaB
    replied
    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)

    Leave a comment:


  • NewCode
    replied
    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:


  • NinjaTrader_ChelseaB
    replied
    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]);
    }
    Below is a publicly available link to the help guide on the DataSeries class.
    https://ninjatrader.com/support/help...ries_class.htm

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by yeshujbp, Today, 08:10 PM
0 responses
1 view
0 likes
Last Post yeshujbp  
Started by backtester831, Today, 06:54 PM
0 responses
1 view
0 likes
Last Post backtester831  
Started by frayrengytrader, Today, 06:03 PM
0 responses
3 views
0 likes
Last Post frayrengytrader  
Started by JustAFish, Today, 05:29 PM
0 responses
5 views
0 likes
Last Post JustAFish  
Started by TraderCAD, Today, 04:27 PM
1 response
8 views
0 likes
Last Post TraderCAD  
Working...
X