波幅较大容易赚到钱
void 一键多挂单不重复(int magic号码,string 品种,double 多挂单点数,double 手数,double 挂单止损,double 挂单止盈,int 滑点,string 挂多注释)
{
int 多挂单数量=0;
for(int f=OrdersTotal()-1; f>=0; f--)
{
if(OrderGetTicket(f)>0)
{
if(OrderGetString(ORDER_SYMBOL)==Symbol()&&OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_STOP&&OrderGetInteger(ORDER_MAGIC)==magic号码)
{
多挂单数量=多挂单数量+1;
}
}
}
if(多挂单数量==0)
{
double 挂单进场价格=SymbolInfoDouble(品种,SYMBOL_ASK)+多挂单点数*SymbolInfoDouble(品种,SYMBOL_POINT);
MqlTradeRequest request;
MqlTradeResult result;
ZeroMemory(request);
ZeroMemory(result);
request.action=TRADE_ACTION_PENDING;
request.symbol=品种;
request.volume=手数;
request.price=挂单进场价格;
request.sl=request.price-挂单止损*SymbolInfoDouble(request.symbol,SYMBOL_POINT);
request.tp= request.price+挂单止盈*SymbolInfoDouble(request.symbol,SYMBOL_POINT);
request.deviation=滑点;
request.type=ORDER_TYPE_BUY_STOP; //挂单类型
request.type_filling=ORDER_FILLING_FOK|ORDER_FILLING_IOC;//订单执行类型
request.type_time=ORDER_TIME_GTC;
request.expiration=0;
request.comment=挂多注释;
request.magic=magic号码;
if(!OrderSend(request,result))
PrintFormat("订单失败代码:",GetLastError());
PrintFormat("交易返回代码:",result.retcode);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void 一键空挂单不重复(int magic号码,string 品种,double 空挂单点数,double 手数,double 挂单止损,double 挂单止盈,int 滑点,string 挂空注释)
{
int 空挂单数量=0;
for(int f=OrdersTotal()-1; f>=0; f--)
{
if(OrderGetTicket(f)>0&&OrderGetString(ORDER_SYMBOL)==Symbol()&&OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_SELL_STOP&&OrderGetInteger(ORDER_MAGIC)==magic号码)
{
空挂单数量=空挂单数量+1;
}
}
if(空挂单数量==0)
{
double 挂单进场价格=SymbolInfoDouble(品种,SYMBOL_BID)-空挂单点数*SymbolInfoDouble(品种,SYMBOL_POINT);
MqlTradeRequest request;
MqlTradeResult result;
ZeroMemory(request);
ZeroMemory(result);
request.action=TRADE_ACTION_PENDING;
request.symbol=品种;
request.volume=手数;
request.price=挂单进场价格;
request.sl=request.price+挂单止损*SymbolInfoDouble(request.symbol,SYMBOL_POINT);
request.tp= request.price-挂单止盈*SymbolInfoDouble(request.symbol,SYMBOL_POINT);
request.deviation=滑点;
request.type=ORDER_TYPE_SELL_STOP; //挂单类型
request.type_filling=ORDER_FILLING_FOK|ORDER_FILLING_IOC;//订单执行类型
request.type_time=ORDER_TIME_GTC;
request.expiration=0;
request.comment=挂空注释;
request.magic=magic号码;
if(!OrderSend(request,result))
PrintFormat("订单失败代码:",GetLastError());
PrintFormat("交易返回代码:",result.retcode);
}
}
|