Lw2 code

//+------------------------------------------------------------------+
//|                                                         Bar%.mq4 |
//|                                                             K.fx |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "K.fx"
#property link      ""
#property version   "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int candleclose()
{
   double open    = iOpen(_Symbol,PERIOD_CURRENT,1);
   double high    = iHigh(_Symbol,PERIOD_CURRENT,1);
   double low     = iLow(_Symbol,PERIOD_CURRENT,1);
   double close   = iClose(_Symbol,PERIOD_CURRENT,1);

   int range = int ((high-low)/_Point);
   int closerange = 0;
   
   if(open<close) closerange = int ((close-low)/_Point); // Bullish
   else if(open>close) closerange = int ((high-close)/_Point); // Bearish
   
   return (closerange*100)/range;
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Comments

Popular posts from this blog

Lw1 code