Welcome to 4XLab.NET : Forex Lab Community Server Sign in | Join | Faq

Indicators

Started by asimon at 07-25-2006 5:05 PM. Topic has 0 replies.

Print Search
Sort Posts:    
   07-25-2006, 5:05 PM
asimon is not online. Last active: 1/23/2010 8:15:16 PM asimon

Top 10 Posts
Joined on 03-07-2006
Posts 140
Average True Range

public class iATR : iBaseATR
{
   int periods;
   double average;


   iTrueRange TR;
   iSMA SMA;
 
   public iATR(int pPeriods)
   {
      periods = pPeriods;
      average = 0;
      TR =
new iTrueRange();
      SMA =
new iSMA(pPeriods);
   }

   public override void ReceiveTick(double pO, double pH, double pL, double pC)
   {
      TR.ReceiveTick(pO,pH,pL,pC);

      if (TR.isPrimed())
      {
         SMA.ReceiveTick(TR.Value());
      }
   }

   public override double Value()
   {
      double v=0;
      if (isPrimed())
      {
         v = SMA.Value();
      }
      return v;
   }

   // returns true when indicator has seen enough values to compute a result
   // it will never return true if initialization parameters are incorrect
   // this will cause indicator to silently fail and not give results
   // on optimization runs where parameter combination is invalid.
   public override bool isPrimed()
   { 
      bool v = false;
      if (SMA.isPrimed())
      {
         v =
true;
      }
      return v;
   }
}


   Report 
4XLab.NET : For... » 4XLab.NET » Indicators » Average True Range

Powered by Community Server, by Telligent Systems