Custom MA Indi, havn't thought of a name yet

 

Does this indicator formulae already exist and if not, could someone kindly code it for me please.

(Close-Open)/(High-Low)*100

I would like it displayed in a seperate indi window, with an external variable for period.

 
Here you go, no clue what you mean with period
//+------------------------------------------------------------------+
//|                                               BodyRangeRatio.mq4 |
//|                                                           zzuegg |
//|                                       when-money-makes-money.com |
//+------------------------------------------------------------------+
#property copyright "zzuegg"
#property link      "when-money-makes-money.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   for(int i=counted_bars-1;i>=0;i--){
      ExtMapBuffer1[i]=((Close[i]-Open[i])/MathMax((High[i]-Low[i]),1))*100;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
zzuegg:
Here you go, no clue what you mean with period
I assume he/she means that he/she wants to show M15 on a H1 chart, etc. Change the High, Low, etc for iHigh, iLow, etc
 

iBarsShift() not to forget ;)

NOTE: only higher timeframes possibles, as always with MTF indicators without shift, higher timeframes repaint the past.

Had some issues: here is the edited version:

//+------------------------------------------------------------------+
//|                                               BodyRangeRatio.mq4 |
//|                                                           zzuegg |
//|                                       when-money-makes-money.com |
//+------------------------------------------------------------------+
#property copyright "zzuegg"
#property link      "when-money-makes-money.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
extern int period=0;
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   if(period==0) period=Period();
   if(period>=Period()){
   int k;
   for(int i=counted_bars-1;i>=0;i--){
      k=i;
      if(period!=0&&period!=Period()) k=iBarShift(Symbol(),period,Time[i],false);
      ExtMapBuffer1[i]=((iClose(Symbol(),period,k)-iOpen(Symbol(),period,k))/MathMax((iHigh(Symbol(),period,k)-iLow(Symbol(),period,k)),Point))*100;
   }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
zzuegg:

iBarsShift() not to forget ;)

NOTE: only higher timeframes possibles, as always with MTF indicators without shift, higher timeframes repaint the past.

Had some issues: here is the edited version:


Thankyou so much zzuegg, what I meant by period was the same as a moving average, so 14 = the last 14 bars information divided by 14 to get an average figure. A the moment its drawing each bars info. Hope thats clear. Again thankyou.
 
//+------------------------------------------------------------------+
//|                                               BodyRangeRatio.mq4 |
//|                                                           zzuegg |
//|                                       when-money-makes-money.com |
//+------------------------------------------------------------------+
#property copyright "zzuegg"
#property link      "when-money-makes-money.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer1.ma[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_NONE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer1.ma);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
extern int period=0;
extern int Ma.period=14;
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   if(period==0) period=Period();
   if(period>=Period()){
   int k;
   for(int i=counted_bars-1;i>=0;i--){
      k=i;
      if(period!=0&&period!=Period()) k=iBarShift(Symbol(),period,Time[i],false);
      ExtMapBuffer1[i]=((iClose(Symbol(),period,k)-iOpen(Symbol(),period,k))/MathMax((iHigh(Symbol(),period,k)-iLow(Symbol(),period,k)),Point))*100;
   }
   for(i=counted_bars-1;i>=0;i--){
       ExtMapBuffer1.ma[i]=iMAOnArray(ExtMapBuffer1,0,Ma.period,0,MODE_SMA,i);
   }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
// for(int i=counted_bars-1;i>=0;i--){
//    ExtMapBuffer1[i]=((Close[i]-Open[i])/MathMax((High[i]-Low[i]),1))*100;

   for(int i=Bars-counted_bars-1;i>=0;i--){
      ExtMapBuffer1[i]=((Close[i]-Open[i])/MathMax((High[i]-Low[i]),Point))*100;
Called the Flash Point Indicator by some.