您需要 登录 才可以下载或查看,没有帐号?注册
// 2 Bar Trend
extern int ProfitMade=65;
extern int LossLimit=20;
extern double OCSpread=8;
// Bar handling
datetime bartime=0;
bool TradeAllowed=true;
int start()
{
double SL,TP;
double ocs=OCSpread*Point;
// bar counting
//rising
if ( Open[1]+ocs Close[1] Close[1] Open[0] TradeAllowed)
{
//buy
SL=Ask-( LossLimit*Point );
TP=Ask+( ProfitMade*Point );
OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, 2Bar ,55555,White);
TradeAllowed=false;
}
//falling
if ( Open[1] Close[1]+ocs Close[1] Open[0] TradeAllowed)
{
//sell
SL=Ask+( LossLimit*Point );
TP=Ask-( ProfitMade*Point );
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,SL,TP, 2Bar ,55555,Red);
TradeAllowed=false;
}
} //start
复制代码
麻烦谁给加个移动止损,拜托了
添加止损函数:bool moving_stoploss_by_point(int order_ticket, int stoploss_point, color colour=CLR_NONE){
if(!OrderSelect(order_ticket,SELECT_BY_TICKET,MODE_TRADES)) return(false);
double open_price=OrderOpenPrice();
double stop_loss=OrderStopLoss();
if (stop_loss==0.0) stop_loss=OrderOpenPrice();
if(OrderType()==OP_BUY Bid-stop_loss =2.0*stoploss_point*Point){
if(OrderModify(order_ticket,open_price,stop_loss+stoploss_point*Point,OrderTakeProfit(),0,colour)) return(true);
}
if(OrderType()==OP_SELL stop_loss-Ask =2.0*stoploss_point*Point){
if(OrderModify(order_ticket,open_price,stop_loss-stoploss_point*Point,OrderTakeProfit(),0,colour)) return(true);
}
return(false);
}
外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!