First program -- How do orders work?

 

Hello,

I have made this program, but somehow I can't see my orders being executed, nor the alerts being triggered when the price has moved by 10 pips :

int init()
  {
   return(0);
  }
  
int deinit()
  {
   return(0);
  }
  

double orderStartPrice = 0;
double takeProfit = 0.001;
double stopLoss = 0.001;
bool verbosed = false;

int start()
  {
   if (orderStartPrice == 0) {
     double startingPrice = Ask;
     OrderSend(Symbol(), 0, 10000, startingPrice, 0.00002, Ask-stopLoss, Ask+takeProfit, "Buy position processed through MQL4");
     orderStartPrice = startingPrice;
     Alert ("Order placed at price ", orderStartPrice);
   }
   
   if (verbosed == false && (Bid < Ask-stopLoss || Bid > Ask+takeProfit)){
      Alert ("Position should have been closed by now");
      verbosed = true;
   }
   return(0);
  }
 
SaigueFault:

Hello,

I have made this program, but somehow I can't see my orders being executed, nor the alerts being triggered when the price has moved by 10 pips :

Please read the documentation: OrderSend()

Please read and implement this: What are Function return values ? How do I use them ?

 
SaigueFault:

Hello,

I have made this program, but somehow I can't see my orders being executed, nor the alerts being triggered when the price has moved by 10 pips :

      // check for long position (BUY) possibility
      if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
         MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious)
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
           }
         else Print("Error opening BUY order : ",GetLastError()); 
         return(0); 
        }

Do you know that you get two examples of EA's the moment you get MT4

MACD Sample and Moving Average

this code comes from MACD Sample

do some testing with those programs

read the comment of RaptorUK open the links he is giving

might you see and understand what function ticket has inside MACD Sample