Hi guys,
I am trying to convert this MQ4 code for Demark's elliott wave into Amibroker afl code. At the moment, I am fairing miserably. I'll post the code here. Any help will be appreciated. If I can complete the code, I'll share it here as expected on the forum.
This at the very beginning itself is confusing me
if(time!=Time[0]){for(i = 0; i < Bars; i++)
ObjectDelete(""+i);time=Time[0];}
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 limit = 500;//Bars - counted_bars;
int waveNumber = 0;
I have already converted the Bool function to amibroker function but I can't get a move on the loop due to this first set of arguments.
I am trying to convert this MQ4 code for Demark's elliott wave into Amibroker afl code. At the moment, I am fairing miserably. I'll post the code here. Any help will be appreciated. If I can complete the code, I'll share it here as expected on the forum.
Code:
//+------------------------------------------------------------------+
//| TD D-Wave.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://ift.tt/186D45t |
//+------------------------------------------------------------------+
#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 |
//+------------------------------------------------------------------+
int deinit() {
for(i = 0; i < Bars; i++)
ObjectDelete(""+i);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
if(time!=Time[0]){for(i = 0; i < Bars; i++)
ObjectDelete(""+i);time=Time[0];}
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 limit = 500;//Bars - counted_bars;
int waveNumber = 0;
// For all bars starting 21 days from the earliest
for(int 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)) {
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;
}
}
}
return(0);
}
bool isMinClose(int daysBack, int startDay) {
for (int 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])
return (false);
}
return (true);
}
bool isMaxClose(int daysBack, int startDay) {
for (int 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])
return (false);
}
return (true);
}
This at the very beginning itself is confusing me
if(time!=Time[0]){for(i = 0; i < Bars; i++)
ObjectDelete(""+i);time=Time[0];}
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 limit = 500;//Bars - counted_bars;
int waveNumber = 0;
I have already converted the Bool function to amibroker function but I can't get a move on the loop due to this first set of arguments.
Elliot Wave - TD D wave - need help converting from MQ4 to AFL
Aucun commentaire:
Enregistrer un commentaire