Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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]);
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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 Taddypole, 04-26-2024, 02:47 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_Eduardo  
          Started by futtrader, 04-21-2024, 01:50 AM
          6 responses
          58 views
          0 likes
          Last Post futtrader  
          Started by sgordet, Today, 11:48 AM
          0 responses
          4 views
          0 likes
          Last Post sgordet
          by sgordet
           
          Started by Trader146, Today, 11:41 AM
          0 responses
          5 views
          0 likes
          Last Post Trader146  
          Started by jpapa, 04-23-2024, 07:22 AM
          2 responses
          22 views
          0 likes
          Last Post rene69851  
          Working...
          X