return(0);
}
---------------------------
The last parameter of iMA function is the shift relative to the current bar the given amount of periods ago. Now if you are interested to include the current running bar in your calculation then put 0 instead of 1. If you put 1 it is the previous bar.

I have replaced PRICE_CLOSED with PRICE_TYPICAL so you can see live how the EMA value changes as the bar size changes in realtime.
Also the second parameter is 1, this means you are using M1 timeframe, I hope this is what you intend.
And finally the iteration will tell you how many times the Start() function was called since the indicator was applied on the chart.

return(0);
}
---------------------------
The last parameter of iMA function is the shift relative to the current bar the given amount of periods ago. Now if you are interested to include the current running bar in your calculation then put 0 instead of 1. If you put 1 it is the previous bar.

I have replaced PRICE_CLOSED with PRICE_TYPICAL so you can see live how the EMA value changes as the bar size changes in realtime.
Also the second parameter is 1, this means you are using M1 timeframe, I hope this is what you intend.
And finally the iteration will tell you how many times the Start() function was called since the indicator was applied on the chart.

Just load it on a 1M chart and see how it chages. Hope it helps.

Ignored

Hi Soso_beton,

thanks for the hint.
I copied exactly you modified script, but doesn't work. Iterations stays always to 1, so the start() is never triggered.
I dont know what to think.
My MT4 version is the last Version 4, build 195, 20 July 2006.

Did you try if on your mt4 works ?

yes, I intented to use on 1M chart.

I wonder if all this ema cross programs around are working and what is so strange is this simple code.

Hi all, after three weeks of having this alert that i downloaded from this thread on my charts it is finaly driving me nuts that it is sending out alerts after the close of nearly every bar after a cross. It took a while for me to notice as i have it set at 30/78 on a five minute chart. The code does do all it is suposed to such as send email, audio, and draw the arrows at the cross. But it will also send out an email/audio alert at each bar close and i'm stumped to figure out just what in the code is telling it to do so.

I have uploaded the indicator and here is the link to it if anyone is up to looking at it. It is probably nothing more that a simple tweak, but i'm at a loss to find it at this stage:

Hi Robik, Im afraid is still not working. I dont know why.
the script is very simple. I have put a counter, so i know how many times the start() function is called, unless, everytime the start() is called all the variables are reset.

So the result of the script is that the counter doesn't increase, like the start() is not called anymore, and also the 2 emas stay always the same.
This is the code.

( if i restart manually the script on the graph it works, only the first call)
I compiled it as a program, maybe should be an indicator ?
Thanks very much if you can help me with this

I think you are using your code as a script, which will only be starting once!
It will be working OK as an Indicator or EA. Please try it out.
Other possibility within a script loop: use RefreshRates() and Sleep() for continuous update within the script
and for not using too much processing time. Example follows.

thanks for the hint.
I copied exactly you modified script, but doesn't work. Iterations stays always to 1, so the start() is never triggered.
I dont know what to think.
My MT4 version is the last Version 4, build 195, 20 July 2006.

Did you try if on your mt4 works ?

yes, I intented to use on 1M chart.

I wonder if all this ema cross programs around are working and what is so strange is this simple code.

Thanks.

Ignored

Scripts will be started only once. The following code (endless loop) will do what you want:

SendMail ("Message from WhyLose's EA", "There was a BUY signal generated on the Dollar/Loony pair!" );

It really is as simple as that one line of code.

The first string (between the first pair of quotes) will be the email message's Subject.

The second string will be the main body of the message.

Insert it in your code in an appropriate place.
For instance, directly after an OrderSend command.
...Or maybe you have your EA generating a sound alert or something. You could place it in that same position or there abouts.

The only other preparation you need is to have your email details setup in MT4's Tools->Options->Email screen.

I was looking through the forum for a guide on how to learn the programming language for MT4. I realise most people would have better things to do but I was wondering if anyone could direct me to a resource on how to create EAs from scratch or make one for me. Im looking for an email alert when my 5 lwma crosses my 12 lwma and has closed crossed. I dont want to be alerted untill the 1h bar has closed and the MA's have officially closed crossed since the MAs could cross and uncross several times untill the bar has been completed. Any help anyone can give would be fantastic.

I was looking through the forum for a guide on how to learn the programming language for MT4. I realise most people would have better things to do but I was wondering if anyone could direct me to a resource on how to create EAs from scratch or make one for me. Im looking for an email alert when my 5 lwma crosses my 12 lwma and has closed crossed. I dont want to be alerted untill the 1h bar has closed and the MA's have officially closed crossed since the MAs could cross and uncross several times untill the bar has been completed. Any help anyone can give would be fantastic.

FJ

Ignored

Hi

I think an EMA cross-over indi already exists. Do a search on the forum. Otherwise, if you find something similar that could be modified to achieve what you want, please post it here and I'll give it a crack.

If after these efforts you still have nothing, I'll see what I can do.