I'm doing this. What is wrong? How it is done correctly? .

 
What is the general structure of an EA?  

What is wrong in that code? How it is done correctly?

when I do the testing, using  "Print (" error ", GetLastError ());" it say "error 4054". But when I give opening that message, the txt says "Error 131".

I'm doing this:


void OnTick()
  {
   double TEND1, TEND2;
 
   TEND1= iADX(NULL,14,PERIOD_M15,PRICE_CLOSE, MODE_PLUSDI,1);
   TEND2= iADX(NULL,14,PERIOD_M15,PRICE_CLOSE, MODE_PLUSDI,2);
  
 
 
//---
   if (OrdersTotal()==0 && TEND1>TEND2)
      {
      int ticket=OrderSend(Symbol(),OP_BUY,0.01, Ask, 10, Ask-500*Point, Ask+500*Point, NULL, 0, 0, clrNONE);
     
      }
   Print("error", GetLastError());
  }

 
   TEND1= iADX(NULL,PERIOD_M15,14,PRICE_CLOSE, MODE_PLUSDI,1);
   TEND2= iADX(NULL,PERIOD_M15,14,PRICE_CLOSE, MODE_PLUSDI,2);
 
trader201:  What is wrong
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Don't double post
Reason: