• 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

help calculate the formula of VA (value area) inside the bar

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

    help calculate the formula of VA (value area) inside the bar

    Hello everyone, help calculate the formula of VA (value area) inside the bar.

    now I already have a code which is determined by the POC inside the bar, help calculate VA.


    thank you in advance.

    #2
    Hello memonolog,

    Thank you for your note.

    Would you please provide more information on what you mean by value area?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      below picture that I need ...

      Click image for larger version

Name:	VAs.png
Views:	1
Size:	18.7 KB
ID:	886665



      https://ibb.co/j6DfUS

      Here is a piece of the original code of the indicator, which determines the POC and VA High and VA Low inside BAR

      Code:
      valueAreaPercent		= 68.27;
      
      valueAreaFac = valueAreaPercent / 100;
      
      //
      
      foreach (KeyValuePair<double, VolItem> element in dictionaryList[i])
      				{
      					valueVol += element.Value.total;
      					priceList.Add(element.Key);
      				}
      				valueVol = (long)(valueVol * valueAreaFac);
      				priceList.Sort();
      
      				for (int n = 0; n <= priceList.Count - 1; ++n)
      				{
      					if (priceList[n] == poc)
      					{
      						highIdx = n;
      						lowIdx = highIdx;
      						break;
      					}
      				}
      				areaVol = dictionaryList[i][poc].total;
      
      				while (areaVol < valueVol)
      				{
      					if (upTestV == 0)
      					{
      						for (int n = 1; (n <= smoothVA && highIdx < priceList.Count - 1); ++n)
      						{
      							upTestV += dictionaryList[i][priceList[highIdx + 1]].total;
      							++highIdx;
      						}
      					}
      
      					if (dnTestV == 0)
      					{
      						for (int n = 1; (n <= smoothVA && lowIdx > 0); ++n)
      						{
      							dnTestV += dictionaryList[i][priceList[lowIdx - 1]].total;
      							--lowIdx;
      						}
      					}
      
      					if (upTestV > dnTestV)
      					{
      						areaVol += upTestV;
      						upTestV = 0;
      					}
      					else
      					{
      						areaVol += dnTestV;
      						dnTestV = 0;
      					}
      				}
      				valueAreaHigh = priceList[highIdx];
      				valueAreaLow = priceList[lowIdx];

      Here is my indicator that defines the POC inside the bar.


      Code:
       double POC = 0;
                              long max = 0;
                              double max_POC = 0;
      
                              {
                                  foreach (KeyValuePair<double, long> kvp in t.dctLast)
                                      if (kvp.Value > max) { max = kvp.Value; max_POC = kvp.Key; }
                                  prc = max_POC;
                              }

      Help me with a formula , how to calculate and distribute VA High and VA Low inside BAR
      Last edited by memonolog; 05-03-2018, 07:44 AM.

      Comment


        #4
        Hello memonolog,

        Would the following be the values from the indicator be what you are looking for?

        Code:
        valueAreaHigh = priceList[highIdx];
        valueAreaLow = priceList[lowIdx];
        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_AlanP View Post
          Hello memonolog,

          Would the following be the values from the indicator be what you are looking for?

          Code:
          valueAreaHigh = priceList[highIdx];
          valueAreaLow = priceList[lowIdx];
          I look forward to your reply.
          Yes , true

          Comment


            #6
            Originally posted by NinjaTrader_AlanP View Post
            Hello memonolog,

            Would the following be the values from the indicator be what you are looking for?

            Code:
            valueAreaHigh = priceList[highIdx];
            valueAreaLow = priceList[lowIdx];
            I look forward to your reply.
            Can you help?

            Comment


              #7
              Hello memonolog,

              So I may best assist you will you please provide more information on what you're looking to do? Those values are already calculated , are you looking to access them from another indicator or strategy?

              I look forward to your reply.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_AlanP View Post
                Hello memonolog,

                So I may best assist you will you please provide more information on what you're looking to do? Those values are already calculated , are you looking to access them from another indicator or strategy?

                I look forward to your reply.
                Yes, how to make the calculation in my code?:

                Code:
                double POC = 0;
                                        long max = 0;
                                        double max_POC = 0;
                
                                        {
                                            foreach (KeyValuePair<double, long> kvp in t.dctLast)
                                                if (kvp.Value > max) { max = kvp.Value; max_POC = kvp.Key; }
                                            prc = max_POC;
                                        }
                please help

                Comment


                  #9
                  Hello memonolog,

                  The easiest method for referencing the variables valueAreaHigh and valueAreaLow from within your indicator would be to modify the original indicator by adding 2 plots and setting those plots to these variables. You would then be able to call this indicator and reference those plots the same way the SampleSMACross strategy references the SMA, because the SMA sets a plot.

                  Code you would add to the original indicator,

                  Code:
                  if (State == State.SetDefaults)
                  {
                  AddPlot(Brushes.Orange, "PlotA");
                  AddPlot(Brushes.Brown, "PlotB");
                  }
                  protected override void OnBarUpdate()
                  {
                  Values[0][0]= valueAreaHigh;
                  Values[1][0]= valueAreaLow;
                  }
                  Which you could reference from your indicator via,

                  Code:
                  OriginalIndicator().PlotA[0];
                  OriginalIndicator().PlotB[0];
                  Please let us know if you need further assistance.
                  Alan P.NinjaTrader Customer Service

                  Comment


                    #10
                    Could you please share the rest of the code for calculating the VA High and VA Low?


                    Originally posted by memonolog View Post


                    Here is a piece of the original code of the indicator, which determines the POC and VA High and VA Low inside BAR

                    Code:
                    valueAreaPercent = 68.27;
                    
                    valueAreaFac = valueAreaPercent / 100;
                    
                    //
                    
                    foreach (KeyValuePair<double, VolItem> element in dictionaryList[i])
                    {
                    valueVol += element.Value.total;
                    priceList.Add(element.Key);
                    }
                    valueVol = (long)(valueVol * valueAreaFac);
                    priceList.Sort();
                    
                    for (int n = 0; n <= priceList.Count - 1; ++n)
                    {
                    if (priceList[n] == poc)
                    {
                    highIdx = n;
                    lowIdx = highIdx;
                    break;
                    }
                    }
                    areaVol = dictionaryList[i][poc].total;
                    
                    while (areaVol < valueVol)
                    {
                    if (upTestV == 0)
                    {
                    for (int n = 1; (n <= smoothVA && highIdx < priceList.Count - 1); ++n)
                    {
                    upTestV += dictionaryList[i][priceList[highIdx + 1]].total;
                    ++highIdx;
                    }
                    }
                    
                    if (dnTestV == 0)
                    {
                    for (int n = 1; (n <= smoothVA && lowIdx > 0); ++n)
                    {
                    dnTestV += dictionaryList[i][priceList[lowIdx - 1]].total;
                    --lowIdx;
                    }
                    }
                    
                    if (upTestV > dnTestV)
                    {
                    areaVol += upTestV;
                    upTestV = 0;
                    }
                    else
                    {
                    areaVol += dnTestV;
                    dnTestV = 0;
                    }
                    }
                    valueAreaHigh = priceList[highIdx];
                    valueAreaLow = priceList[lowIdx];

                    Here is my indicator that defines the POC inside the bar.


                    Code:
                    double POC = 0;
                    long max = 0;
                    double max_POC = 0;
                    
                    {
                    foreach (KeyValuePair<double, long> kvp in t.dctLast)
                    if (kvp.Value > max) { max = kvp.Value; max_POC = kvp.Key; }
                    prc = max_POC;
                    }

                    Help me with a formula , how to calculate and distribute VA High and VA Low inside BAR

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by digibob, Today, 03:45 AM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_Jim  
                    Started by waldoalvarez, Yesterday, 04:59 PM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by jayfutures23, Today, 07:06 AM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_Melissa  
                    Started by MojoJojo, Today, 05:59 AM
                    3 responses
                    11 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Spark68, Yesterday, 07:48 PM
                    1 response
                    19 views
                    0 likes
                    Last Post NinjaTrader_PaulH  
                    Working...
                    X