I have 1 error in this code i tried to convert from MQ4 to AFL. Could anyone please tell me what I did wrong here? I'm new to looping. Just figured out how to create a function in C++ and so I have managed to modify this a bit.
It seems to be a syntax error somewhere but I can't find it.
It seems to be a syntax error somewhere but I can't find it.
Code:
//+------------------------------------------------------------------+
//| TD D-Wave.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
/*#property copyright "clam61"
#property link ""
#property indicator_chart_window
*/
//---- input parameters
/*
datetime time;
int i;
*//*
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
return(0);
}*/
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
//for(i = 0; i < BarCount; i++)
// ObjectDelete(""+i);
// return(0);
//}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
//start() {
SetBarsRequired(sbrAll);
i=0;
TimeNum()==0;
counted_bars = BarCount;
daysback=0;
dist= 1.5*ATR(10);
function isMaxClose(daysBack,startDay) {
for ( i = 1; i < daysBack + 1; i++) {
//if today's close less than a close in the past x days
if (Close[startDay] <= Close[startDay + i])
false;
}
return (True);
}
function isMinClose(daysBack,startDay) {
for (i = 1; i < daysBack + 1; i++) {
//if today's close greater than a close in the past x days
if (Close[startDay] >= Close[startDay +i ])
False;
}
return (True);
}
for(i = 0; i < BarCount; i++) {
// for (i=0; i < BarCount; i++) {
// if(TimeNum()> 0);
//ObjectDelete(""+i);time=Time[0];}
counted_bars = BarCount;
// check for possible errors
if(counted_bars < 0)
-1;
// last counted bar will be recounted
if(counted_bars>0)
counted_bars--;
limit = 500;//Bars - counted_bars;
waveNumber = 0;
// For all bars starting 21 days from the earliest
for(i = limit - 22; i >= 0; i--) {
//If wave has not started
if (waveNumber == 0) { //Alert("0");
//find a 21 day low
if (isMinClose(21, i)) {
PlotText( "1" , i , H[i]+dist[i]*0.15, colorBlack );
//ObjectCreate(""+i, OBJ_TEXT, 0, Time[i], Low[i] - 10 * Point );
// ObjectSetText(""+i, "A", 15, "Arial", Lime);
waveNumber = 1;
}
}
else if (waveNumber == 1) {
//find a 13 day high
if (isMaxClose(13, i)) {
//ObjectCreate(""+i, OBJ_TEXT, 0, Time[i], High[i] + 10 * Point );
//ObjectSetText(""+i, "1", 15, "Arial", Lime);
waveNumber = 2;
}
}
else if (waveNumber == 2) {
//find a 8 day low
if (isMinClose(8, i)) {
//ObjectCreate(""+i, OBJ_TEXT, 0, Time[i], Low[i] - 10 * Point );
//ObjectSetText(""+i, "2", 15, "Arial", Lime);
waveNumber = 3;
}
}
else if (waveNumber == 3) {
//find a 21 day high
if (isMaxClose(21, i)) {
// ObjectCreate(""+i, OBJ_TEXT, 0, Time[i],High[i] + 10 * Point );
// ObjectSetText(""+i, "3", 15, "Arial", Lime);
waveNumber = 4;
}
}
else if (waveNumber == 4) {
//find a 13 day low
if (isMinClose(13, i)) {
// ObjectCreate(""+i, OBJ_TEXT, 0, Time[i],Low[i] - 10 * Point );
// ObjectSetText(""+i, "4", 15, "Arial", Lime);
waveNumber = 5;
}
}
else if (waveNumber == 5) {
//find a 34 day high
if (isMaxClose(34, i)) {
// ObjectCreate(""+i, OBJ_TEXT, 0, Time[i],High[i] + 10 * Point );
// ObjectSetText(""+i, "5", 15, "Arial", Lime);
waveNumber = 0;
}
}
}