The Lab of FX Automated Trading
Tutorials on automatic FX trading with MetaTrader 4
5. Create a Sample Program (3)
2. Command to Take a Short Position
Out of three major commands, so far we covered one.
3 major components of the program (reprise):
- A command to take long position(←This is covered)
- A command to take short position
- 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.
- //----
- // SHORT
- double min = Low[iLowest(NULL,PERIOD_H1,MODE_LOW,BreakPeriod,1)];
- if(Low[0] <= min && OrdersTotal() < 1){
- OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Bid+StopLoss*Point, NULL, NULL, 0, 0, Red);
- }
- //----
