Hello,
I try since some days to learn to program with the metaeditor in MT4.
But I dont have success with my first indicator.
Please can someone have a look on following code what is wrong.
Result should be : on every new candle should print a number 1,2,3..... íf it close under the HighestHigh of 5 periods.
Im desparte
Thank you for answers
*********************************** **********************
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color1 Gold
double ExtMapBuffer1[];
double ExtMapBuffer2[];
// Initialisierung zum Indikatorstart
int init()
{
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
return(0);
}
//+------------------------------------ ----------------+
// Deinitialisierung zum Indikatorende
int deinit()
{
return(0);
}
//+------------------------------------ ----------------+
// Hauptroutine
int start()
{
int limit;
int start = 0;
int counted_bars = IndicatorCounted();
// nothing else to do?
if(counted_bars < 0)
return(-1);
// do not check repeated bars
limit = Bars - 1 - counted_bars;
for(int i = 0; i<limit; i++)
{
ExtMapBuffer1=High;
if (Close<ExtMapBuffer1)
ExtMapBuffer2 = ExtMapBuffer2+1;
else ExtMapBuffer2=0;
string name = "NR1" + TimeToStr(Time, TIME_DATE|TIME_MINUTES);
ObjectCreate(name, OBJ_TEXT, 0, Time, High+2);
ObjectSetText(name, ExtMapBuffer1, 7, "Times New Roman", Gold);
string name1 = "NR2" + TimeToStr(Time, TIME_DATE|TIME_MINUTES);
ObjectCreate(name1, OBJ_TEXT, 0, Time, High+3);
ObjectSetText(name1, ExtMapBuffer2, 7, "Times New Roman", Red);
}
return(0);
}
//+------------------------------------ ----------------+Try this one : _test.mq4
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I try since some days to learn to program with the metaeditor in MT4.
But I dont have success with my first indicator.
Please can someone have a look on following code what is wrong.
Result should be : on every new candle should print a number 1,2,3..... íf it close under the HighestHigh of 5 periods.
Im desparte
Thank you for answers
*********************************** **********************
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color1 Gold
double ExtMapBuffer1[];
double ExtMapBuffer2[];
// Initialisierung zum Indikatorstart
int init()
{
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
return(0);
}
//+------------------------------------ ----------------+
// Deinitialisierung zum Indikatorende
int deinit()
{
return(0);
}
//+------------------------------------ ----------------+
// Hauptroutine
int start()
{
int limit;
int start = 0;
int counted_bars = IndicatorCounted();
// nothing else to do?
if(counted_bars < 0)
return(-1);
// do not check repeated bars
limit = Bars - 1 - counted_bars;
for(int i = 0; i<limit; i++)
{
ExtMapBuffer1=High;
if (Close<ExtMapBuffer1)
ExtMapBuffer2 = ExtMapBuffer2+1;
else ExtMapBuffer2=0;
string name = "NR1" + TimeToStr(Time, TIME_DATE|TIME_MINUTES);
ObjectCreate(name, OBJ_TEXT, 0, Time, High+2);
ObjectSetText(name, ExtMapBuffer1, 7, "Times New Roman", Gold);
string name1 = "NR2" + TimeToStr(Time, TIME_DATE|TIME_MINUTES);
ObjectCreate(name1, OBJ_TEXT, 0, Time, High+3);
ObjectSetText(name1, ExtMapBuffer2, 7, "Times New Roman", Red);
}
return(0);
}
//+------------------------------------ ----------------+