//+------------------------------------------------------------------+ //| ZIG-ZAG-ORDER.mq4 | //| Copyright 2017,MarcovdHeijden, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017,MarcovdHeijden, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property show_inputs static input double lots=0.01;// Orderlots int ticket; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //+------------------------------------------------------------------+ //if(zag>zig) indicator shows down //if(zig>zag) indicator shows up //+------------------------------------------------------------------+ int n=0; int i=1; double zig=0; double zag=0; //+------------------------------------------------------------------+ while(n<2) { if(zig>0) zag=zig; zig=iCustom(NULL,0,"ZigZag",0,i); if(zig>0) n+=1; i++; } //+------------------------------------------------------------------+ if(MathMax(zig,zag)>Ask) { ticket=OrderSend(Symbol(),OP_BUYSTOP,lots,MathMax(zig,zag),3,0,0,"zigzag",0,0,clrRed); { if(ticket==-1) { Alert("Error ordering zigzag buystop"); } } } //+------------------------------------------------------------------+ if(MathMin(zig,zag)<Bid) { ticket=OrderSend(Symbol(),OP_SELLSTOP,lots,MathMin(zig,zag),3,0,0,"zigzag",0,0,clrRed); { if(ticket==-1) { Alert("Error ordering zigzag sellstop"); } } } //+------------------------------------------------------------------+ Comment("ZIG: ",zig," ZAG: ",zag); } //+------------------------------------------------------------------+
It's a SCRIPT, so place it in the right folder, you click it once then it will place buy and sell stop just once.
If you are talking about an error, name the error,
Saying makes error means nothing.
Here is the compiled file put it in the scripts folder.
If you are talking about an error, name the error,
Saying makes error means nothing.
Here is the compiled file put it in the scripts folder.
thank you Marco
| Don't post a link to or attach a image, just insert the image |
Forum on trading, automated trading systems and testing trading strategies
Modify error 130 in small TimeFrame
Alain Verleyen, 2017.07.26 17:11
Please take into account my advice about using html table uselessly.
Forum on trading, automated trading systems and testing trading strategies
General rules and best pratices of the Forum.
Alain Verleyen, 2017.03.09 17:27
- General rules, enforced by moderators :
5. Repeated violation of the Rules, ignoring moderator's remarks and open disrespect for the website Administration will lead to an account termination.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please help to build a simple EA which only place;
one buy stop on last zigzag top
one sell stop on last zigzag bottom
thank you