Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Same recorded result for all bars

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

    Same recorded result for all bars


    the indicator put same result for all bars, I guess it doesn´t reset the variables, how to reset them ("calculo" and "std")?

    publicclass IntradayIntensity : Indicator
    {
    #region Variables
    privateint period = 21;
    privatedouble calculo = 0;
    private double std = 0;
    #endregion

    protectedoverridevoid Initialize()
    {
    Add(
    new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Bar, "IntradayIntensity"));
    Overlay =
    false;
    BarsRequired =
    21;
    }
    protectedoverridevoid OnBarUpdate()
    {
    int i = CurrentBar - 21;

    if (i>=0)

    {
    for (int k = i; k < CurrentBar; k++)

    {
    if (High[k]-Low[k] != 0)

    calculo = (((
    2*Close[k]-High[k]-Low[k])/(High[k]-Low[k]))*Volume[k]);

    std = std + calculo;
    }

    Value.Set(std);
    }
    }

    #2
    Hello,

    You will need to determine a condition to reset these variables when true. When would you like the variables to reset? For example, you could reset them using the FirstTickOfBar:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Well I'm trying to code this formula

      IIstd = Sum21 ((2C-H-L)/(H-L))xV

      the idea it's using loop function "for" in orther to get the 21 bars ago sum of ((2C-H-L)/(H-L))xV in the current bar.

      I'm doing it ok?

      Comment


        #4
        fercho,

        As long as you are declaring them as 0 after the rest of your logic, they should be set to 0 once OnBarUpdate has completed.


        Please try adding std = 0 in OnBarUpdate after Value.Set

        You would repeat this for any variables you need to reset.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Intraday Intensity Index (standard version)

          Well, It worked without the looping thing, anyway it was a pain in the a** all the copy/paste work for 21 bars summation ... hope learn some day how to do it

          What Does Intraday Intensity Index Mean?
          A volume based indicator that depicts the flow of funds for a security according to where it closes in its high and low range. Calculated as:

          IIstd = Sum21 ((2C-H-L)/(H-L))xV

          Read as:

          The 21 bars summation of (2 *Close- High - Low) divided by (High-Low) all multiplied by the Volume of each day.

          more info at:

          Attached Files

          Comment


            #6
            Originally posted by fercho View Post
            Well, It worked without the looping thing, anyway it was a pain in the a** all the copy/paste work for 21 bars summation ... hope learn some day how to do it

            What Does Intraday Intensity Index Mean?
            A volume based indicator that depicts the flow of funds for a security according to where it closes in its high and low range. Calculated as:

            IIstd = Sum21 ((2C-H-L)/(H-L))xV

            Read as:

            The 21 bars summation of (2 *Close- High - Low) divided by (High-Low) all multiplied by the Volume of each day.

            more info at:

            http://www.tradingprofessionale.it/i...art=754&ids=no
            I already showed you a more efficient routine in the other thread you posted on this same topic.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by PaulMohn, Today, 03:49 AM
            0 responses
            7 views
            0 likes
            Last Post PaulMohn  
            Started by inanazsocial, Today, 01:15 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by rocketman7, Today, 02:12 AM
            0 responses
            10 views
            0 likes
            Last Post rocketman7  
            Started by dustydbayer, Today, 01:59 AM
            0 responses
            4 views
            0 likes
            Last Post dustydbayer  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            5 responses
            23 views
            0 likes
            Last Post trilliantrader  
            Working...
            X