我们在市价以上5个点挂一个0.1手突破多单,止盈为20个点,止损为5个点,然后在市价以下5个点挂一个0.1手突破空单,同样止盈20个点,止损5个点。代码如下:
- void OnStart()
- {
- double lot=0.1;
- int huadian=10;
- int tp=20;
- int sl=5;
- double Price_BUY= MarketInfo(Symbol(), MODE_ASK)+
- 5 *(MarketInfo(Symbol(), MODE_POINT)* 10);
- double tp_BUY= Price_BUY+tp*(MarketInfo(Symbol(),
- MODE_POINT)* 10);
- double sl_BUY= Price_BUY-sl*(MarketInfo(Symbol(),
- MODE_POINT)* 10);
- int ticket= OrderSend (Symbol(),OP_BUYSTOP,lot, Price_BUY,huadian, sl_BUY, tp_BUY,"MQL4 Lesson",1000,0, clrAliceBlue);
-
- double Price_SELL= MarketInfo(Symbol(), MODE_BID)-
- 5 *(MarketInfo(Symbol(), MODE_POINT)* 10);
- double tp_SELL= Price_SELL-tp*(MarketInfo(Symbol(),
- MODE_POINT)* 10);
- double sl_SELL= Price_SELL+sl*(MarketInfo(Symbol(),
- MODE_POINT)* 10);
- ticket= OrderSend (Symbol(),OP_SELLSTOP,lot, Price_SELL,huadian, sl_SELL, tp_SELL,"MQL4 Lesson",1000,0, clrAliceBlue);
- }
复制代码
|