![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
...
Doc
The indicator itself does not do that but it is using all in all 18 instances of indicators from 3 different time frames.
Apart from a big number of indicators used internally, in my experience metatrader 5 has some problems multi time frame operating (for example I saw examples when on one tick it returns all OK and on the next tick it returns an error "saying" that the target time frame does not exist, while the time frame did not change in the meantime at all) I do not know what does it do in cases when it fails to find a target time frame, but, if it resets, then you have the built in indicators calculating all the bars again. Unfortunately you can not do anything to improve that. As I said one "some maturity is still needed for metatrader 5 to become serious platform"
Thanks,
I asked you this, cause the indicator is really slow if I set the maximum bar's number in my chart...any suggestion could be great!
Regards
docTrend alexcud + alert
look at first post
Regards
doc
Doc
The indicator itself does not do that but it is using all in all 18 instances of indicators from 3 different time frames.
Apart from a big number of indicators used internally, in my experience metatrader 5 has some problems multi time frame operating (for example I saw examples when on one tick it returns all OK and on the next tick it returns an error "saying" that the target time frame does not exist, while the time frame did not change in the meantime at all) I do not know what does it do in cases when it fails to find a target time frame, but, if it resets, then you have the built in indicators calculating all the bars again. Unfortunately you can not do anything to improve that. As I said one "some maturity is still needed for metatrader 5 to become serious platform"Thanks mladen for your patience,
I just add the final mq5 file of trend alexcud in the first post...
Have a nice weekend and best regards.
doc
Doc Use this one as a template. In the end you will find a working alerting code (there is no alert on current since this one is not a "buffering" one but is always calculating the current values). Alerting code is just above the text changing code so you can use same sets of conditions for alerts. I did not do that since I simply do not know what kind of alerts did you have in mind
Mladen,
how could I have an alert that warns only once and not every open bar?
Regards
doc
...
Doc
It would have to be written differently
For example, this would be the code for the template that would alert only when the condition changes :
{
if (uitog1v >= overPerc || ditog1v >= overPerc)
{
static datetime time1 = 0;
static string mess1 = "";
if (uitog1v >= overPerc) doAlert(time1,mess1,0," Alexcud changed to up");
if (ditog1v >= overPerc) doAlert(time1,mess1,0," Alexcud changed to down");
}
}
[/PHP]
As you can see time of the alert (originally it was time[rates_total-1]) is replaced with 0 (so it will not take into account the time of the bar issued, that way it will ignore a new bar) and it will alert only if the kind of the alert changed (the "up" or the "down") Just make sure that it can not have both conditions true (in that case you would not like what you get, since you would have 2 alerts on each and every tick
)
For this kind of alerting you have to have an "opposite" alert too otherwise it would alert you once and it would not alert you ever more. In this case also, if you have a repeated alert after "retracing" it will not alert you either. For that (to alert you when it re-enters some kind of a "signal") you would need something like this[PHP]if(AlertsOn)
{
static datetime time1 = 0;
static string mess1 = "";
while (true)
{
if (uitog1v >= overPerc) { doAlert(time1,mess1,0," Alexcud changed to up"); break; }
if (ditog1v >= overPerc) { doAlert(time1,mess1,0," Alexcud changed to down"); break; }
doAlert(time1,mess1,0," Alexcud is in no trend zone"); break;
}
}
This way you would have one new kind of an alert (call it "retrace") which would ensure that when the "up" zone or the "down" zone are re-entered, you are alerted (new alert is not going to be raised until it retraces or has an opposite signal - so again it will alert only when the "kind" of alert changes)
PS: the last code will alert you on intial start too (since it will be in any of the 3 "states") but it will obey the rules described above
Mladen,
how could I have an alert that warns only once and not every open bar?
Regards
docDoc
It would have to be written differently
For example, this would be the code for the template that would alert only when the condition changes :
{
if (uitog1v >= overPerc || ditog1v >= overPerc)
{
static datetime time1 = 0;
static string mess1 = "";
if (uitog1v >= overPerc) doAlert(time1,mess1,0," Alexcud changed to up");
if (ditog1v >= overPerc) doAlert(time1,mess1,0," Alexcud changed to down");
}
}
[/PHP]
As you can see time of the alert (originally it was time[rates_total-1]) is replaced with 0 (so it will not take into account the time of the bar issued, that way it will ignore a new bar) and it will alert only if the kind of the alert changed (the "up" or the "down") Just make sure that it can not have both conditions true (in that case you would not like what you get, since you would have 2 alerts on each and every tick
)
For this kind of alerting you have to have an "opposite" alert too otherwise it would alert you once and it would not alert you ever more. In this case also, if you have a repeated alert after "retracing" it will not alert you either. For that (to alert you when it re-enters some kind of a "signal") you would need something like this[PHP]if(AlertsOn)
{
static datetime time1 = 0;
static string mess1 = "";
while (true)
{
if (uitog1v >= overPerc) { doAlert(time1,mess1,0," Alexcud changed to up"); break; }
if (ditog1v >= overPerc) { doAlert(time1,mess1,0," Alexcud changed to down"); break; }
doAlert(time1,mess1,0," Alexcud is in no trend zone"); break;
}
}
This way you would have one new kind of an alert (call it "retrace") which would ensure that when the "up" zone or the "down" zone are re-entered, you are alerted (new alert is not going to be raised until it retraces or has an opposite signal - so again it will alert only when the "kind" of alert changes)
PS: the last code will alert you on intial start too (since it will be in any of the 3 "states") but it will obey the rules described aboveWOW!![](https://c.mql5.com/forextsd/smiles/teeth_smile.png)
What can I say? Thank you very very much for this great explanation! (very important for a beginner like me)
Last question:
is it difficult to insert an "nbars" input int parameter? For me it's difficult cause I don't know how to start, there's no calculation or loop like "for (int i=(int)MathMax... " to try to modify.
Best regards
doc
...
Doc
That indicator would need to be rewriten from the scratch then (since, as far as I see, it was written with only one idea : to calculate current values and all the code was done that way : object creations (they are created one by one instead of using some procedure for that that would make the code much easier to alter), temporary values, no calculating buffers nor arrays ...)
But then I have a question too: do you really need that? Since the concept of the indicator is to show current value, not historical values, how would it look with looped calculation and what would be the visual presentation then?
WOW!
What can I say? Thank you very very much for this great explanation! (very important for a beginner like me)
Last question:
is it difficult to insert an "nbars" input int parameter? For me it's difficult cause I don't know how to start, there's no calculation or loop like "for (int i=(int)MathMax... " to try to modify.
Best regards
docDoc
That indicator would need to be rewriten from the scratch then (since, as far as I see, it was written with only one idea : to calculate current values and all the code was done that way : object creations (they are created one by one instead of using some procedure for that that would make the code much easier to alter), temporary values, no calculating buffers nor arrays ...)
But then I have a question too: do you really need that? Since the concept of the indicator is to show current value, not historical values, how would it look with looped calculation and what would be the visual presentation then?Dear mladen,
I don't try to make a loop, but I would like to have a right calculation...probably as you said it's a metatrader problem, because if I attach this indy to a 10.000 bars chart and than to a 30.000 bars chart, I see a big difference (3x times slower) and I don't understand the reason cause it shouldn't count all bars but only what needed, so the max ma's value and nothing more...
How could I have something like this:
rates_total= max ma's value (so it calculates only the right bar's number needed)
Is it possible?
Regards
doc
...
Doc
Can you post the version that is causing you that problems?
Dear mladen,
I don't try to make a loop, but I would like to have a right calculation...probably as you said it's a metatrader problem, because if I attach this indy to a 10.000 bars chart and than to a 30.000 bars chart, I see a big difference (3x times slower) and I don't understand the reason cause it shouldn't count all bars but only what needed, so the max ma's value and nothing more...
How could I have something like this:
rates_total= max ma's value (so it calculates only the right bar's number needed)
Is it possible?
Regards
docDoc Can you post the version that is causing you that problems?
Good morning mladen!
yap sure, this is my little mod...here I used cci cause the calculation is more complex and slow than ma calculation (so it's easier to see differences in indy's loading time).
Please try it before with 5000 bars chart and than with 1.000.000 bars chart what a big difference loading time.
Best regards
doc
prova3.mq5