Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Loading days in the indicator regardless of the chart

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

    Loading days in the indicator regardless of the chart

    Loading days in the indicator regardless of the chart

    Hello everyone, there was a task to implement loading of days in the indicator regardless of the chart

    Using an additional data series with a time pattern (I added data series)

    Code:
    AddDataSeries(Instrument.FullName, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, "Forex");
    Indicated that the code is being executed for the second data series

    Code:
    if (BarsInProgress == 1)
    in order to avoid drawing breaks on timeframes like tick and range, indicated that we are drawing on the first data series (chart data series)

    Code:
    if (BarsInProgress == 0)
    {
    
    Values[0][0] = (iCumTypicalVolume / iCumVolume);
    }
    }
    Please tell me what's next? how I can implement this task?

    Thanks in advance.

    Here is my indicator code

    Code:
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class VWAP8 : Indicator
    {
    double iCumVolume = 0;
    double iCumTypicalVolume = 0;
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Volume Weighted Average Price";
    Name = "VWAP8";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = false;
    DrawOnPricePanel = false;
    DrawHorizontalGridLines = false;
    DrawVerticalGridLines = false;
    PaintPriceMarkers = false;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    AddPlot(new Stroke(Brushes.SpringGreen, DashStyleHelper.Solid, 5), PlotStyle.Line, "VWAP");
    
    }
    else if (State == State.Configure)
    {
    AddDataSeries(Instrument.FullName, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, "Forex");
    }
    
    }
    
    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    {
    
    if (Bars.IsFirstBarOfSession)
    {
    iCumVolume = VOL()[0];
    iCumTypicalVolume = VOL()[0] * ((High[0] + Low[0] + Close[0]) / 3);
    }
    else
    {
    iCumVolume = iCumVolume + VOL()[0];
    iCumTypicalVolume = iCumTypicalVolume + (VOL()[0] * ((High[0] + Low[0] + Close[0]) / 3));
    }
    }
    
    if (BarsInProgress == 0)
    {
    
    Values[0][0] = (iCumTypicalVolume / iCumVolume);
    }
    }
    
    #region Properties
    
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> PlotVWAP
    {
    get { return Values[0]; }
    }
    #endregion
    
    }
    }
    Last edited by memonolog; 11-29-2020, 01:48 AM.

    #2
    Hello memonolog,

    Use the int barsToLoad overload with AddDataSeries() and custom calculate a number of bars for the number of days you would like.
    https://ninjatrader.com/support/help...dataseries.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello memonolog,
      custom calculate a number of bars for the number of days you would like
      I added a series of data with the number of bars, I need help further, I don't quite understand how to find out the number of bars per day

      Code:
       AddDataSeries(Instrument.FullName, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, 100, "Forex", true);
      Don't know how to implement this, there is an example where it is implemented?
      Last edited by memonolog; 11-29-2020, 11:43 PM.

      Comment


        #4
        Hello memonolog,

        A day has 1440 minutes in it. You could try using multiples of 1440 as the barsToLoad.

        AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, 2880, "Forex", true);

        This will depend on how many bars you want to load.

        Also, it is not supported to use Instrument.FullName in State.Configure. Use null instead as directed in the help guide Tip #4.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello memonolog,

          A day has 1440 minutes in it. You could try using multiples of 1440 as the barsToLoad.

          AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, 2880, "Forex", true);

          This will depend on how many bars you want to load.

          Also, it is not supported to use Instrument.FullName in State.Configure. Use null instead as directed in the help guide Tip #4.
          Thanks, for a minute is clear, but if it is range bars or Tick. how then to solve the Task?

          Comment


            #6
            Hello memonolog,

            The amount of ticks in a day will vary. I would recommend trying a high number, and then check the date of Times[1][0] on the first bar, and adjust accordingly.

            I will also add your vote to feature request SFT-4583, 'Way to specify the amount of days to load for AddDataSeries'.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by POTTER16, Today, 03:31 PM
            0 responses
            6 views
            0 likes
            Last Post POTTER16  
            Started by enricbcn, 05-08-2018, 01:36 AM
            78 responses
            43,520 views
            1 like
            Last Post Wessel
            by Wessel
             
            Started by Wessel, Today, 12:50 PM
            0 responses
            8 views
            0 likes
            Last Post Wessel
            by Wessel
             
            Started by asmmbillah, Today, 12:39 PM
            0 responses
            8 views
            0 likes
            Last Post asmmbillah  
            Started by dtmtradingco, Today, 12:30 PM
            0 responses
            7 views
            0 likes
            Last Post dtmtradingco  
            Working...
            X