I need a simple Indicator: Median Price (Open + Close/2)

 

I would hope and think that this one is easy, I'm just too new to MQL4 programming to do it yet...

Can anyone out there build me a simple indicator that is similar to the Moving Average indicator of Period: 1, Shift: 0, MA Method: Simple, Apply To: Median Price (HL/2) Style: Blue line BUT... replace Apply To: Median Price (HL/2) with Apply To: Median Price (Open+Close/2) ?

I need a blue line that progressively connects all price bars (no matter what time frame selected on the chart) in which the connection points represent the Median Price of the Open + Close divided by 2 of each bar.

Please reply and attach indicator to your post. Thank you in advance!

 
//+------------------------------------------------------------------+
//|                                        TypicalPriceOpenClose.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
//---- 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 limit = Bars - IndicatorCounted();
   
   for(int i = limit; i >= 0; i--){
   ExtMapBuffer1[i] = (Open[i]+Close[i])/2.0;
}

   return(0);
  }
 
phy wrote >>

Thanks so much phy, I compiled it and it works like a charm!

You seem to be one of the most knowledgeable veterans on this forum. I have been studying this forum for about a month now and only registered yesterday. I have a few questions for you:

1) What EA have you seen to date that impresses you the most and why?

2) Are there any video tutorial courses you can recommend to a newbie (with very limited programming background) who really wants to learn MQL4 programming?

Again, thank you so kindly for the indicator :)

 

1) none.

2) To learn to code, you must sit with the document, and a few simple examples, and just do it. Start simple. Build on what you learn, experiment.

3) The main ingredient for a good programmer is to have imagination and be able to think of a way to use what is available to do what you want to do.

 
phy wrote >>

1) none.

2) To learn to code, you must sit with the document, and a few simple examples, and just do it. Start simple. Build on what you learn, experiment.

3) The main ingredient for a good programmer is to have imagination and be able to think of a way to use what is available to do what you want to do.

Thanks phy. Good advice and much appreciated.

 

Solid advice from Phy.

I would also add:

MQL is very OOP with the different methods and functions you can create. Chances are the functions already exist, you just have to track them down and modify. Spend A LOT of time with the EAs on the site. Even the ones that are rated poorly or not downloaded often can teach you something. I'm working on mine and have pulled the indicators from one EA, the money mgmt from another EA, trailing stops from a third, etc. It's all out there, you just have to take the time to understand the code and implement into your own project.

 
LongToBeFree wrote >>

Solid advice from Phy.

I would also add:

MQL is very OOP with the different methods and functions you can create. Chances are the functions already exist, you just have to track them down and modify. Spend A LOT of time with the EAs on the site. Even the ones that are rated poorly or not downloaded often can teach you something. I'm working on mine and have pulled the indicators from one EA, the money mgmt from another EA, trailing stops from a third, etc. It's all out there, you just have to take the time to understand the code and implement into your own project.

Thanks to you as well LongToBeFree. Nice to see there is so much support and good advice around here for a newbie like myself. My best to you all!

 

Do not post to this thread without an exceptionally good reason . . .

Thread start date - 2008.10.22