Quick pointer on how this indicator rounds to 4 decimal places....

 

Hi

Here is the ATR indicator in mt4:

#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int AtrPeriod=14;
//---- buffers
double AtrBuffer[];
double TempBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 1 additional buffer used for counting.
   IndicatorBuffers(2);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,AtrBuffer);
   SetIndexBuffer(1,TempBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="ATR("+AtrPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,AtrPeriod);
//----

   return(0);
  }

//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   if(Bars<=AtrPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=AtrPeriod;i++) AtrBuffer[Bars-i]=0.0;
//----
   i=Bars-counted_bars-1;
   while(i>=0)
     {
      double high=High[i];
      double low =Low[i];
      if(i==Bars-1) TempBuffer[i]=high-low;
      else
        {
         double prevclose=Close[i+1];
         TempBuffer[i]=MathMax(high,prevclose)-MathMin(low,prevclose);
        }
      i--;
     }
//----
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   for(i=0; i<limit; i++){AtrBuffer[i]=iMAOnArray(TempBuffer,Bars,AtrPeriod,0,MODE_SMA,i);}

   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

It outputs to 4 decimal places, eg: 0.0023 can anyone show me were this is set in the above code?

Thanks

Antony

 
I don't understand your question. What should it be if not 0.0023?
 
ubzen:
I don't understand your question. What should it be if not 0.0023?


Hi

The 0.0023 is jsut an example, it always displays 0.**** which is 4 digits after the decimal point, I was wondering how it does this as I need to change it to 0.*** 3 digits, if this is possible.

Thanks

Antony

 
tonyjms2005:


Hi

The 0.0023 is jsut an example, it always displays 0.**** which is 4 digits after the decimal point, I was wondering how it does this as I need to change it to 0.*** 3 digits, if this is possible.

Thanks

Antony


NormalizeDouble()
 
NormalizeDouble(double variable, Digits);
 

can someone help me edit sar ohlc to use heiken ashi ohlc

Hi, I have an MTF indicator that uses sar, however I'd like the sar to calculate heiken ashi ohlc, and not the normal type

Can you tell me how I can do this, my mtf indicator calls to the sar indicator to calculate sar formula, I think it is calling to the internal indicator in mt4 that can not edit

you can skype or email if you can assist and like to talk about it

skype sty671

email sty671@gmail.com

I can also supply the original file that I'm trying to use heiken ashi ohlc for

Reason: