Pending stop orders placed on zigzag top and bottom programming code in mql4 needed

 

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

 
//+------------------------------------------------------------------+
//|                                                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.

 
Marco vd Heijden:

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.


thank you Marco but i need EA which place automatically a pending order when a top or bottom is formed
 

Well you can modify it into an EA or post a job in Freelance.

 
Marco vd Heijden:

Well you can modify it into an EA or post a job in Freelance.


when i compile your script code, that makes error, i ont understand

 

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.

Files:
 
Marco vd Heijden:

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
 
patrick020170:

thank you Marco


a screenshot of errors on my compiler

Files:
errors.JPG  41 kb
 
patrick020170: a screenshot of errors on my compiler
Don't post a link to or attach a image, just insert the image
 
whroeder1:

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.


 

Excuse me? What remarks?

2017.07.26 11:47

2017.07.26 11:11

2017.07.26 11:40   You are referring to tables, all your duplicate posts are about comments posted before I read your first mentioned problem.

2017.07.25 10:03 Edited, no tables. Does that look better?

Reason: