• 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

Double WMA

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

    Double WMA

    I'm trying to code a Double WMA. I've got the WMA code in front of me:

    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);
    }
    }
    and I'm guessing I might only need to add another Set after the "Value.Set(val / weight);" line, plus add an extra plot and so on.

    So far though I can't figure it, any help appreciated.

    Thanks,
    Jeremy

    #2
    If your WMA doesn't differ from the one that comes with NT.
    Code:
    Value.Set( WMA( WMA( Input, Period1 ), Period2 ) );
    should do everything you need.
    Last edited by Rollins; 01-06-2008, 08:21 AM.

    Comment


      #3
      Can you be a little more specific about what you're trying to do? In particular, why do you need both values to be in the same indicator instead of using two instances?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Birdseye, Today, 04:52 AM
      0 responses
      3 views
      0 likes
      Last Post Birdseye  
      Started by U0000999, Today, 03:43 AM
      0 responses
      4 views
      0 likes
      Last Post U0000999  
      Started by NinjaCustomer, Today, 03:22 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by MarianApalaghiei, Today, 01:26 AM
      0 responses
      9 views
      0 likes
      Last Post MarianApalaghiei  
      Started by seagraph, Yesterday, 03:27 PM
      0 responses
      14 views
      0 likes
      Last Post seagraph  
      Working...
      X