5. Create a Sample Program (3)

Bookmark and Share

2. Command to Take a Short Position

Out of three major commands, so far we covered one. 

3 major components of the program (reprise):

  1. A command to take long position(←This is covered
  2. A command to take short position
  3. A command to settle current positions (trailing)

Programming the command to take a short position is simple. 
It varies little from the command to take a long position, which we have developed already. 

  1. //----
  2. // SHORT
  3.   double min = Low[iLowest(NULL,PERIOD_H1,MODE_LOW,BreakPeriod,1)];
  4.   if(Low[0] <= min && OrdersTotal() < 1){
  5.     OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Bid+StopLoss*Point, NULL, NULL, 0, 0, Red);
  6.   }
  7. //----
up