Hello everyone...
Thanks to CodersGuru and his excellent course, I am attempting to learn MQL4
by converting an indicator I wrote in MQL3.
I have run into a snag and would appreciate some help... if someone could please tell me what I am doing wrong in the following code.
The problem is in the 2 If statements... at line 78 & 79
//+------------------------------------------------------------------+
//| First_Indicator.mq4 |
//| Codersguru |
//|
http://www.forex-tsd.com |
//+------------------------------------------------------------------+
#property copyright "Codersguru"
#property link "http://www.forex-tsd.com"
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Red
//---- buffers
double ExtMapBuffer1[];
//----------------- Variable Declarations ----------------------+
int pos=0;
double Pivot_Point = 0;
double new_Pivot_Point =0;
double prev_Pivot_Point=0;
double Pivot_Factor=0;
double LastClose=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0,ExtMapBuffer1);
string short_name = "Pivot Line";
IndicatorShortName(short_name);
return(1);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//---- check for possible errors
if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
if (counted_bars>0) counted_bars--;
int cnt=Bars-counted_bars;
//---- main calculation loop
while(cnt >= 0)
{
LastClose = Close[cnt];
If (LastClose > Pivot_Point) //Line 78
If(new_Pivot_Point > prev_Pivot_Point) //Line 79
{
prev_Pivot_Point = new_Pivot_Point;
Pivot_Point = new_Pivot_Point;
}
ExtMapBuffer1[cnt]= Pivot_Point ;
cnt--;
}
return(0);
}
These are the compiler messages -
---------------------------------------------------------------
'If' - function is not defined .....(78,10)
'If' - semicolon expected .....(79,13)
'If' - function is not defined ...(79, 13)
'{' - semicolon expected ....(80, 13)
----------------------------------------------------------------
No matter what I do, I can't seem to come up with what the problem is... I know it is very simple, but it is escaping me...
Thanks to all who can assist in this basic question....
Chief
P.S. Happy, Healthy, Prosperous New Year to ALL
