Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Time Frame Indicator based on Range

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

    Multi Time Frame Indicator based on Range

    I have simple MTF Indicators (SMA and EMA) based on Range. How it is possible that sometimes when I use data from 15 days my Indicators are in a chart (for example GC , 12 Better Renko chart), but when I give some other value for example 30 days of data they disappear from a chart L.
    Maybe somebody who develops indicators knows how to fix it?
    My code for EMAclose based on Range is:
    PHP Code:
    protected override void Initialize()
    {
    Add(new Plot(Color.GreenPlotStyle.Line"Plot0"));
    Add(PeriodType.Rangerange); 
    Overlay true;
    PriceTypeSupported true;
    //AutoScale = false;
    BarsRequired 20;


    }
     
     
    protected 
    override void OnBarUpdate()
    {
    Value.Set(CurrentBar == Input[0] : Input[0] * (2.0 / (Period)) + (- (2.0 / (Period))) * Value[1]);

     
    if(
    CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
    return; 

     
    Plot0.Set(Closes[1][0]);

    Thanks in advance

    #2
    Hello,

    Thanks for the note.

    You need to make sure you are loading enough data for the indicator to be able to function.

    In this case it most likely is more then 30 bars, try increasing this to see if you can get it to replot.

    Finally, what is the error in the log tab in the Control Center.

    -Brett
    BrettNinjaTrader Product Management

    Comment


      #3
      MTF Indic based on Range

      I don't have any errors now when I load, before I was had this error:
      Error on calling 'OnBarUpdate' method for indicator 'EMAmtfRangeClose' on bar 1: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

      I change the value for Bars Required to 50, but I don’t think that is the problem, because 30 days are more data than 15 days – more bars.

      Any other idea ?

      Comment


        #4
        Hello,

        What type of Range and Renko bars are you using what periods?

        Also since you are not getting the log error anymore is it now plotting?

        -Brett
        BrettNinjaTrader Product Management

        Comment


          #5
          mtf indiactors

          Indicators are based on Range 13, chart is GC 04-12, BetterRenko 12.
          I don't have any error when I'm adding indicators to a chart.
          Like before I don't have plots on 30 days chart, but I have it on 15 days.

          Comment


            #6
            Hello,

            Can you please post full code as a .cs file from the MyDocuments->NinjaTrader7->bin->custom->indicators->InidcatorName.cs so that I can give this a quick run on my side. Normally we do not debug for clients however I will take a quick run to see if I can see anything obvious.

            -Brett
            BrettNinjaTrader Product Management

            Comment


              #7
              mtf indicators

              I put does indicators as attachments, but if you prefer code directly, you have it below:

              publicclassEMAmtfRangeClose : Indicator
              {
              #region Variables
              privateint period = 13;
              privateint range = 13;
              #endregion
              ///<summary>
              /// This method is used to configure the indicator and is called once before any bar data is loaded.
              ///</summary>
              protectedoverridevoid Initialize()
              {
              Add(
              new Plot(Color.Green, PlotStyle.Line, "Plot0"));
              Add(PeriodType.Range, range);
              Overlay =
              true;
              PriceTypeSupported =
              true;
              //AutoScale = false;//
              BarsRequired = 50;//


              }

              ///<summary>
              /// Called on each bar update event (incoming tick)
              ///</summary>
              protectedoverridevoid OnBarUpdate()
              {
              Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);

              if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
              return;

              Plot0.Set(Closes[1][0]);
              }
              Attached Files

              Comment


                #8
                Hello wlodi,
                Thanks for the code and I am replying for Brett.

                Unfortunately I couldn’t replicate the issue, but you can have an situation where the secondary bar series is yet to form (though the primary series might have more bars that BarsRequired) and if you call the Closes[1][0] then you will get an index out of range error.

                The issue may vary depending on how the bars are made, and not how much data is being loaded.

                Please let me know if I can assist you any further.
                JoydeepNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by salination2, Yesterday, 07:21 PM
                1 response
                4 views
                0 likes
                Last Post s.kinra
                by s.kinra
                 
                Started by aarons34, Yesterday, 08:11 PM
                0 responses
                6 views
                0 likes
                Last Post aarons34  
                Started by Shiner452, Yesterday, 06:55 PM
                0 responses
                2 views
                0 likes
                Last Post Shiner452  
                Started by Aquatrade, Yesterday, 06:22 PM
                0 responses
                3 views
                0 likes
                Last Post Aquatrade  
                Started by trader3000a, Yesterday, 02:04 PM
                2 responses
                24 views
                0 likes
                Last Post trader3000a  
                Working...
                X