You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I am writing the indicator which makes an alert when ma crosses the price. But during the compilation there are two errors - "unexpected token" in the two lines - I underlined these two lines.
Could you tell me what should I add to the code that it works?
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[],ma[];
double Zmienna1[];
double Zmienna2[];
extern int MAType = 1;
extern int MAPeriod = 34;
extern int MAShift = 0;
extern int PriceType=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(5);
//---- drawing settings
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ma);
SetIndexStyle(0,DRAW_LINE,0,2);
SetIndexStyle(1,DRAW_LINE,0,2);
SetIndexBuffer(3,Zmienna1);
SetIndexBuffer(4,Zmienna2);
//---- initialization done
return(0);
}
int start()
{
for(int i = Bars-10; i >= 0; i--)
{
ma[i]=iMA(NULL,0,MAPeriod,MAShift,MAType,PriceType,i);
}
for(int shift = Bars-10; shift >= 0; shift--)
{
ExtMapBuffer1[shift] = ma[shift];
ExtMapBuffer2[shift] = ma[shift];
// Print (ma[shift]);
if (ma[shift] > ma[shift+1])
{
Zmienna1[1] = 1;
else Zmienna1[1] = 2;
else if (ma[shift+1] > ma[shift+2])
Zmienna2[1] = 2;
else Zmienna2[1] = 1;
if (Zmienna1[1] != Zmienna2[1])
MessageBox("Uwaga1","Uwaga2");
}
}
return(0);
}
//////////////////////////////////////
best regards,
jajaceek