![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Dearest MLADEN,
may be my previous request accidentally deleted as mostly things running here and there,looking and adjust their exact place but we are easy and comfort with doing our job,as a reminder i request you for some simple trailing stop with BE code that i want add/merge in attached EA that i altered with your kind help and guidance,but i am not in hurry,when it is possible for you,i know how much stuff spread-ed and waiting for you,thanks.
regards
simple_ma_cross_eamod-hp.mq4OK. Will be done![](https://c.mql5.com/forextsd/smiles/smile.png)
Hi all,
Thanks for taking the time to read my post. I am an absolute newbie when it comes to code. I tried a couple of things to get this EA to work but they were not the answer. I am studying global variables as I think it needs this to remember what has occurred instead of restarting when a refresh/reload etc has occurred. It works perfectly in a backtest but for some reason when running live it will just stop taking trades or closing them for that matter and I just cannot figure it out. I am also trying to learn how to do these things but I am only just starting so forgive me if I do things the wrong way. The EA has a start and stop time and in that time it can open x trades and when this closes then a cycle completes. It is set to allow only 1 cycle per time period.
Can someone look at this code to see what the problem is please. Many thanks for any help
maa1
quantum_shaolin_1.3.2.mq4
quantum.mq4
Hello Mladen,
I have a scanner indicator that tells how many indicators indicate a buying or selling opportunity in a particular symbol, and it scans the symbol on multiple timeframes.
The problem is that the indicator says that there are always indicators indicating, even when they in fact don't. When this is the case the indicator amount is always the same number.
Please look at the code below:
int Timeframe[7][3]={15,,, 60,,, 240,,, 1440,,, 10080,,, 43200,, ,,};
for(x=0; x<=5; x++) {
if ((SymbolBars[y][x]==iBars(symbol[y],Timeframe[x][0]))&&(SymbolBars[y][x+1]==iBars(symbol[y],Timeframe[x+1][0]))) continue;
BufferALL[0]=indi1(symbol[y],Timeframe[x][0]);
//BufferALL[1]=ind2i(symbol[y],Timeframe[x][0]);
BufferALL[2]=ind3i(symbol[y],Timeframe[x][0]);
BufferALL[3]=ind4i(symbol[y],Timeframe[x][0]);
BufferALL[4]=ind5i(symbol[y],Timeframe[x][0]);
BufferALL[5]=indi(symbol[y],Timeframe[x][0]);
BufferALL[6]=indi(symbol[y],Timeframe[x][0]);
BufferALL[7]=indi(symbol[y],Timeframe[x][0]);
BufferALL[8]=indi(symbol[y],Timeframe[x][0]);
BufferALL[9]=indi(symbol[y],Timeframe[x][0]);
BufferALL[10]=indi(symbol[y],Timeframe[x][0]);
BufferALL[11]=indi(symbol[y],Timeframe[x][0]);
BufferALL[12]=indi(symbol[y],Timeframe[x][0]);
BufferALL[13]=indi(symbol[y],Timeframe[x][0]);
BufferALL[14]=indi(symbol[y],Timeframe[x][0]);
BufferALL[15]=indi(symbol[y],Timeframe[x][0]);
BufferALL[16]=indi(symbol[y],Timeframe[x][0]);
BufferALL[17]=indi(symbol[y],Timeframe[x][0]);
BufferALL[18]=indi(symbol[y],Timeframe[x][0]);
BufferALL[19]=indi(symbol[y],Timeframe[x][0]);
BufferALL[20]=indi(symbol[y],Timeframe[x][0]);
BufferALL[21]=indi(symbol[y],Timeframe[x][0]);
for(z=0; z<=14; z++){
if (BufferALL[z] >=534653647457) Timeframe[x][1]=Timeframe[x][1]+1;
if (BufferALL[z] <=543456346463) Timeframe[x][2]=Timeframe[x][2]+1;
}
for(z=15; z<=21; z++){
if (BufferALL[z] >= 22345654) Timeframe[x][2]=Timeframe[x][2]+1; //>
if (BufferALL[z] <= 11111111111) Timeframe[x][1]=Timeframe[x][1]+1; //<
}
} // end of timeframe loop 6 iterations
When everything gets displayed in a alert message i get something like EURUSD: 15m/60m/4u/1d/1w/1mo is indicating a buying opportunity 7/7/7/7/7/7/.
This means that it summed 7 indicators for each timeframe which clearly is erroneous. It even states this when i take out all the function calls. When i do this all the elements of BufferALL[] are empty.
But apperently the value EMPTY is still a value that can be compared with another value like 534653647457 for example. When i use the comparison >= or = 534653647457 to == 534653647457 the /7/7/7/7/7/7/7 messages stop. How can i remedy this?
Hello Mladen,
I have a scanner indicator that tells how many indicators indicate a buying or selling opportunity in a particular symbol, and it scans the symbol on multiple timeframes.
The problem is that the indicator says that there are always indicators indicating, even when they in fact don't. When this is the case the indicator amount is always the same number.
Please look at the code below:
int Timeframe[7][3]={15,,, 60,,, 240,,, 1440,,, 10080,,, 43200,, ,,};
for(x=0; x<=5; x++) {
if ((SymbolBars[y][x]==iBars(symbol[y],Timeframe[x][0]))&&(SymbolBars[y][x+1]==iBars(symbol[y],Timeframe[x+1][0]))) continue;
BufferALL[0]=indi1(symbol[y],Timeframe[x][0]);
//BufferALL[1]=ind2i(symbol[y],Timeframe[x][0]);
BufferALL[2]=ind3i(symbol[y],Timeframe[x][0]);
BufferALL[3]=ind4i(symbol[y],Timeframe[x][0]);
BufferALL[4]=ind5i(symbol[y],Timeframe[x][0]);
BufferALL[5]=indi(symbol[y],Timeframe[x][0]);
BufferALL[6]=indi(symbol[y],Timeframe[x][0]);
BufferALL[7]=indi(symbol[y],Timeframe[x][0]);
BufferALL[8]=indi(symbol[y],Timeframe[x][0]);
BufferALL[9]=indi(symbol[y],Timeframe[x][0]);
BufferALL[10]=indi(symbol[y],Timeframe[x][0]);
BufferALL[11]=indi(symbol[y],Timeframe[x][0]);
BufferALL[12]=indi(symbol[y],Timeframe[x][0]);
BufferALL[13]=indi(symbol[y],Timeframe[x][0]);
BufferALL[14]=indi(symbol[y],Timeframe[x][0]);
BufferALL[15]=indi(symbol[y],Timeframe[x][0]);
BufferALL[16]=indi(symbol[y],Timeframe[x][0]);
BufferALL[17]=indi(symbol[y],Timeframe[x][0]);
BufferALL[18]=indi(symbol[y],Timeframe[x][0]);
BufferALL[19]=indi(symbol[y],Timeframe[x][0]);
BufferALL[20]=indi(symbol[y],Timeframe[x][0]);
BufferALL[21]=indi(symbol[y],Timeframe[x][0]);
for(z=0; z<=14; z++){
if (BufferALL[z] >=534653647457) Timeframe[x][1]=Timeframe[x][1]+1;
if (BufferALL[z] <=543456346463) Timeframe[x][2]=Timeframe[x][2]+1;
}
for(z=15; z<=21; z++){
if (BufferALL[z] >= 22345654) Timeframe[x][2]=Timeframe[x][2]+1; //>
if (BufferALL[z] <= 11111111111) Timeframe[x][1]=Timeframe[x][1]+1; //<
}
} // end of timeframe loop 6 iterations
When everything gets displayed in a alert message i get something like EURUSD: 15m/60m/4u/1d/1w/1mo is indicating a buying opportunity 7/7/7/7/7/7/.
This means that it summed 7 indicators for each timeframe which clearly is erroneous. It even states this when i take out all the function calls. When i do this all the elements of BufferALL[] are empty.
But apperently the value EMPTY is still a value that can be compared with another value like 534653647457 for example. When i use the comparison >= or = 534653647457 to == 534653647457 the /7/7/7/7/7/7/7 messages stop. How can i remedy this?mrcodix
Without knowing exactly what the indicators do (what are their return values) all I can do is wild guesses, and that would not help at all
mrcodix
Without knowing exactly what the indicators do (what are their return values) all I can do is wild guesses, and that would not help at allDear Mladen,
You don't have to know the returnvalues because its not the indicators whom are the culprit. You see, the exact same problem arises when i disable all the call functions by adding a "//" in front of each code line (turning them into comment lines). The same goes for the values behind the = at this part:
if (BufferALL[z] >=534653647457) Timeframe[x][1]=Timeframe[x][1]+1;
if (BufferALL[z] <=543456346463) Timeframe[x][2]=Timeframe[x][2]+1;
}
for(z=15; z<=21; z++){
if (BufferALL[z] >= 22345654) Timeframe[x][2]=Timeframe[x][2]+1; //>
if (BufferALL[z] <= 11111111111) Timeframe[x][1]=Timeframe[x][1]+1; //<
}[/CODE]
it might aswell be something like
if (BufferALL[z] >=1111111111111) Timeframe[x][1]=Timeframe[x][1]+1;
if (BufferALL[z] <=2222222222222) Timeframe[x][2]=Timeframe[x][2]+1;
}
for(z=15; z<=21; z++){
if (BufferALL[z] >= 333333333333) Timeframe[x][2]=Timeframe[x][2]+1; //>
if (BufferALL[z] <= 444444444444) Timeframe[x][1]=Timeframe[x][1]+1; //<
}it will give the same exact alert message that says /15m/60m/4u/1d/1w/1mo/ is indicating a buying opportunity /7/7/7/7/7/7/. I disabled all the function call lines with // so the BufferALL[22] elements should be EMPTY, they shoulden't contain any value whatsoever. Yet, when the computer comes at the if condition parts BufferALL[z] >=1111111111111 etc it ALWAYS states that the "value" thats inside BufferALL[z] is larger then 11111111111 (or any value you wish to put behind it). The only way to make these additions stop is by changing the if condition = into ==. When the computer asks whether the empty value of BufferALL[z] is exactly the same as 11111111 or 22222 or whatever value you wish to compare, it doesen't return a true and Timeframe is not added with +1. Please try it for youself. I will add the message construction code below:
[CODE]
int SymbolBars[216][7];
if (((Timeframe[0][1] > 0) && (Timeframe[1][1] > 0) && (SymbolBars[y][0]!=iBars(symbol[y],Timeframe[0][0]))&&(SymbolBars[y][1]!=iBars(symbol[y],Timeframe[1][0]))) || ((Timeframe[1][1] > 0) && (Timeframe[2][1] > 0)&& (SymbolBars[y][1]!=iBars(symbol[y],Timeframe[1][0]))&&(SymbolBars[y][2]!=iBars(symbol[y],Timeframe[2][0]))) || ((Timeframe[2][1] > 0) && (Timeframe[3][1] > 0)
&& (SymbolBars[y][2]!=iBars(symbol[y],Timeframe[2][0]))&&(SymbolBars[y][3]!=iBars(symbol[y],Timeframe[3][0]))) || ((Timeframe[3][1] > 0) && (Timeframe[4][1] > 0) && (SymbolBars[y][3]!=iBars(symbol[y],Timeframe[3][0]))&&(SymbolBars[y][4]!=iBars(symbol[y],Timeframe[4][0]))) || ((Timeframe[4][1] > 0) && (Timeframe[5][1] > 0)&& (SymbolBars[y][4]!=iBars(symbol[y],Timeframe[4][0])) &&(SymbolBars[y][5]!=iBars(symbol[y],Timeframe[5][0]))))
{
if (Timeframe[0][1]>0)
{
StringAdd(alarmbericht,"15m/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[0][1],"/"));
SymbolBars[y][0]=iBars(symbol[y],15);
}
if (Timeframe[1][1]>0)
{
StringAdd(alarmbericht,"60m/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[1][1],"/"));
SymbolBars[y][1]=iBars(symbol[y],60);
}
if (Timeframe[2][1]>0)
{
StringAdd(alarmbericht,"4u/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[2][1],"/"));
SymbolBars[y][2]=iBars(symbol[y],240);
}
if (Timeframe[3][1]>0)
{
StringAdd(alarmbericht,"1d/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[3][1],"/"));
SymbolBars[y][3]=iBars(symbol[y],1440);
}
if (Timeframe[4][1]>0)
{
StringAdd(alarmbericht,"1w/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[4][1],"/"));
SymbolBars[y][4]=iBars(symbol[y],10080);
}
if (Timeframe[5][1]>0)
{
StringAdd(alarmbericht,"1mo/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[5][1],"/"));
SymbolBars[y][5]=iBars(symbol[y],43200);
}
Alert(+symbol[y]+" "+alarmbericht+" are indicating a selling opportunity. " +indicatoraantal+".");
alarmbericht = "";
indicatoraantal = "";
}
if (((Timeframe[0][2] > 0) && (Timeframe[1][2] > 0) && (SymbolBars[y][0]!=iBars(symbol[y],Timeframe[0][0]))&&(SymbolBars[y][1]!=iBars(symbol[y],Timeframe[1][0]))) || ((Timeframe[1][2] > 0) && (Timeframe[2][2] > 0)&& (SymbolBars[y][1]!=iBars(symbol[y],Timeframe[1][0]))&&(SymbolBars[y][2]!=iBars(symbol[y],Timeframe[2][0]))) || ((Timeframe[2][2] > 0) && (Timeframe[3][2] > 0)
&& (SymbolBars[y][2]!=iBars(symbol[y],Timeframe[2][0]))&&(SymbolBars[y][3]!=iBars(symbol[y],Timeframe[3][0]))) || ((Timeframe[3][2] > 0) && (Timeframe[4][2] > 0) && (SymbolBars[y][3]!=iBars(symbol[y],Timeframe[3][0]))&&(SymbolBars[y][4]!=iBars(symbol[y],Timeframe[4][0]))) || ((Timeframe[4][2] > 0) && (Timeframe[5][2] > 0)&& (SymbolBars[y][4]!=iBars(symbol[y],Timeframe[4][0])) &&(SymbolBars[y][5]!=iBars(symbol[y],Timeframe[5][0]))))
{
if (Timeframe[0][2]>0)
{
StringAdd(alarmbericht,"15m/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[0][2],"/"));
SymbolBars[y][0]=Bars(symbol[y],15);
}
if (Timeframe[1][2]>0)
{
StringAdd(alarmbericht,"60m/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[1][2],"/"));
SymbolBars[y][1]=Bars(symbol[y],60);
}
if (Timeframe[2][2]>0)
{
StringAdd(alarmbericht,"4u/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[2][2],"/"));
SymbolBars[y][2]=Bars(symbol[y],240);
}
if (Timeframe[3][2]>0)
{
StringAdd(alarmbericht,"1d/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[3][2],"/"));
SymbolBars[y][3]=Bars(symbol[y],1440);
}
if (Timeframe[4][2]>0)
{
StringAdd(alarmbericht,"1w/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[4][2],"/"));
SymbolBars[y][4]=Bars(symbol[y],10080);
}
if (Timeframe[5][2]>0)
{
StringAdd(alarmbericht,"1mo/");
StringAdd(indicatoraantal,StringConcatenate(Timeframe[5][2],"/"));
SymbolBars[y][5]=Bars(symbol[y],43200);
}
Alert(+symbol[y]+" "+alarmbericht+" are indicating a buying oppertunity. " +indicatoraantal+".");
alarmbericht = "";
indicatoraantal = "";
}Mladen,
Here is an example of the continuous alert messaging when i remove all indicator calls by turning them into comment lines.
When its a buying opportunity all the indicator summations in all the possible time frames is 15. When its a selling opportunity its 7. The BufferALL[] is EMPTY so this doesen't make sense whatsoever.
Lastly, i would like to mention something to you off topic. In the past i asked something about the scanner indicator scanning multiple symbols successively. I was wondering if it would not get all the ticks in the more frequently changing symbols when the indicator is attached to a chart of which the current symbol doesen't update as frequently (less ticks per second). That would mean that in theory the indicator my still be in the 5 minute bar of 20:05 while the faster updating symbols that its also supposed to scan are already at 20:10. Simply because a new bar starts on the first tick after 20:04:59, and not when the clock hits 20:05:00. You responded to this by saying that all the symbols will be checked with a fixed check speed because in the new metatrader version the start {return} procedure is no longer activated on each new tick. Instead its activated in a fixed rate. This turned out not to be true. After turning all my indicators into functions that are included in the code of my scanner indicator itself the whole indicator still made mt4 freeze when i ran it. So using iCustom() to call the code or by inserting the code and turning it into an internal function makes no difference whatsoever, it still freezes. But i've found a solution for this by ditching the 215 iteration long master for loop (each iteration a different symbol out of symbol[y] is being treated) and replacing it with a variable that gets an addition after each tick. I use this to tell the computer which symbol it should use so now instead of trying to analyze all 216 symbols on every tick (which makes the whole thing freeze) only one symbol is being analyzed on each tick. When the addition variable hits 215 it is reset back to 0 and the whole 216 cycle starts over again. Now all the symbols are being analyzed albeit a bit slower then when they would have been analyzed all 216 on every tick (if it wouldrnt freeze offcourse).... Anyway. The point is that Start{} only gets activated when the current symbol in the chart is updating. That means that it takes longer to go thourgh all 216 symbols when the indicator is a less active symbol (like a share) as opposed to a very active symbol (like EURUSD). So Start{} is still activated on each new tick.
Hello Mladen and Mrtools, I ask a great pleasure.
It would be kind to solve the problem of two errors while compiling the indicator attached.
Thank you in advance
Moreno
PS: I'm sorry for my english :-)
Hello Mladen and Mrtools, I ask a great pleasure.
It would be kind to solve the problem of two errors while compiling the indicator attached.
Thank you in advance
Moreno
PS: I'm sorry for my english :-)morenokosta
That indicator us OK as is
No need to make any code change
Hi Mladen
Can you Please add alert on this indicator,I'm a newbie.
Thanx