Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

WMA_Slope_Color?

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

    WMA_Slope_Color?

    (EN)
    Hello, someone who has this flag but instead of being Exponential Moving Average (EMA) refers to Weighted Moving Average (WMA).

    Thanks.

    (ES)
    Hola, alguien que tenga este indicador pero de vez de ser Exponential Moving Average (EMA) haga referencia a Weighted Moving Average (WMA).

    Gracias.
    Attached Files

    #2
    nikelado80, the change should be simple...you would just need to comment the current Value.Set...and replace with the one using WMA smoothing - Value.Set(WMA(Input, Period)[0]);

    Comment


      #3
      (EN)
      Hi Bertrand, I did what you told me you can see below, but still can not see the WMA.
      Will I have to change anything. You can look at the code to see if it is okay?

      Thanks for the help.Escuchar
      Leer fonéticamente

      (ES)
      Hola Bertrand, he hecho lo que me dijiste lo puedes ver abajo, pero sigo sin poder ver la WMA.
      Será que tengo que cambiar otra cosa. Puedes mirar el código para ver si está bien?

      Gracias por la ayuda.


      EMA_Slope_Color


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


      if(Rising(Value))
      {
      if(slopeColor)
      PlotColors[0][0] = upColor;
      }
      if(Falling(Value))
      {
      if(slopeColor)
      PlotColors[0][0] = dnColor;
      }

      }


      WMA

      protected override void OnBarUpdate()
      {
      if (CurrentBar == 0)
      Value.Set(Input[0]);
      else
      {
      int back = Math.Min(Period - 1, CurrentBar);
      double val = 0;
      int weight = 0;
      for (int idx = back; idx >=0; idx--)
      {
      val += (idx + 1) * Input[back - idx];
      weight += (idx + 1);
      }
      Value.Set(val / weight);
      }
      }

      WMA_Slope_Color

      protected override void OnBarUpdate()
      {
      if (CurrentBar == 0)
      Value.Set(Input[0]);
      else
      {
      int back = Math.Min(Period - 1, CurrentBar);
      double val = 0;
      int weight = 0;
      for (int idx = back; idx >=0; idx--)
      {
      val += (idx + 1) * Input[back - idx];
      weight += (idx + 1);
      }
      Value.Set(val / weight);
      }

      if(Rising(Value))
      {
      if(slopeColor)
      PlotColors[0][0] = upColor;
      }
      if(Falling(Value))
      {
      if(slopeColor)
      PlotColors[0][0] = dnColor;
      }

      }

      Comment


        #4
        Do you see any errors in the log tab? There would be no need to calculate the WMA again...it's already available as a method so you only need to use the snippet I posted earlier to call it and put it's values into your indicator's Value.Set to work with it.

        Comment


          #5
          Hi Bertrand, has been pretty easy, I thought it would be much more complicated.

          Thank you very much for your help

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          649 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          576 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X