Another solution Have done it now in mql4 but why can't it this way in mql5
int start() { int counted_bars=IndicatorCounted(); //---- if(ma1[1] < ma2[1]&& ma1[0] > ma2[0] && ma4 != 1) { ma4 = 1; Alert("Cross signal down"); } //---- return(0); }
Another solution Have done it now in mql4 but why can't it this way in mql5
Hi,
this is a script. onstart(). I want it to work in the EA. But only one message in the journal. I want the program to jump over the print until the new signal is comming.
Hi,
this is a script. onstart(). I want it to work in the EA. But only one message in the journal. I want the program to jump over the print until the new signal is comming.
You could use logic of my example to build your own logic. For solve your task you can use global or static variables.
If I correctly understand what you need there is solution:
void OnTick() { //--- //... bool ma4 = false; // value true == Cross signal if(ma1[1]<ma2[1] && ma1[0]>ma2[0]) { if(flag()) { ma4 = true; Alert("Cross signal down"); } } else { ma4 = false; flag(true); // reset } //... } //################################################ //################################################ bool flag(bool reset=false) { static bool flag = true; if(reset) { flag = true; return(false); } if(!flag) return(false); flag = false; return(true); }
Hi,
this is a script. onstart(). I want it to work in the EA. But only one message in the journal. I want the program to jump over the print until the new signal is comming.
Now I don't understand
You want code to print/alert only one time in the journal when ma4 is still in value 1. If you trie it out you can't have more then one alert it can only alert for more times if the bool ma4 = 0; is turning again to zero after each cycle or there is something else in your EA making ma4 equal to zero
@WWer
Yes, it print one time, but I dont get the right Time in the journal. ex The time is 00:00:00 Cross down..
Test it so you will understand it.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Code:
bool ma4 = 0; // value 1 == Cross signal
if(ma1[1] < ma2[1]&& ma1[0] > ma2[0])
ma4 = 1;
Alert("Cross signal down");
Hi,
I want my code to print/alert only one time in the journal when ma4 is still in value 1. Right now my code is printing alot " cross signal down" when ma4 = 1.
Any one can solve this problem?
Thien