Take
#property indicator_chart_window int inddir[1]; string dir[1]; int start() { if(High[1]<High[0]&&inddir[0]!=0){ inddir[0]=0;dir[0]="UP";_object();_alert();} if(Low[1]>Low[0]&&inddir[0]!=1){ inddir[0]=1;dir[0]="DOWN";_object();_alert();} return(0);} //---- void function ---- int _alert(){ Alert(Symbol()," Direction Changed ",dir[0]); return(0);} //---- draw ---- bool _object(){ if(ObjectFind("Direction")>-1)ObjectDelete("Direction"); double price=Bid+(High[0]-Low[0])*2*(0.5-inddir[0]); ObjectCreate("Direction",OBJ_ARROW,0,Time[0],price); ObjectSet("Direction",OBJPROP_ARROWCODE,6); ObjectSet("Direction",OBJPROP_COLOR,Gray); ObjectSet("Direction",OBJPROP_WIDTH,1); return(0);}Or variant with text
Files:
marhighlow_1.mq4
1 kb
Thank you very much!
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
I started learning MQL4 now but it's not easy at the beginning. I am not new to programming (I also program VB, VBA) but the syntax and the declaration of variables seem to be pretty complex. Therefore I want to know if somebody could give me a very short code just for my orientation. The indicator should only play a sound and draw an arrow if the last bar has a higher high then the bar before. That's all. I only want to know how a good programmed code looks like. Then I can use this small code to keep on learning and testing. But at the moment I don't even know how to create a structure in the Metaeditor. I only wrote down // My first MQL4 try... And that's not enough... ;-)
Thank you very much!
Marcus