myeatrade

社区

设置参数breakEven,能不能盈利11点后将止损移动到买入价上面1点的位置?

1597943797 1597943797 2012-10-17 17:16
管理员你好!
设置参数breakEven,能不能在多单盈利超过11点后将止损移动到开仓价上面1点而不是0呢?
如果可以请告诉我修改哪里:
void breakEven(int magic,int BreakEven,double point){
RefreshRates();
if(OrdersTotal()>0){
for(int i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderMagicNumber()==magic){
if(OrderType()==OP_BUY){
if( NormalizeDouble((Bid-OrderOpenPrice()),Digits)>=NormalizeDouble(BreakEven*point,Digits)){
if( (OrderStopLoss()-OrderOpenPrice())<0)
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue);
}
}else{
if( NormalizeDouble((OrderOpenPrice()-Ask),Digits)>=NormalizeDouble(BreakEven*point,Digits)){
if(((OrderOpenPrice()-OrderStopLoss())<0)||(OrderStopLoss()==0))
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
谢谢!


myeatrade myeatrade 2012-10-18 16:09
可以的 将你贴的代码 改为 以下,注意黑体的地方就可以了

void breakEven(int magic,int BreakEven,double point){
RefreshRates();
if(OrdersTotal()>0){
for(int i=0;i<OrdersTotal();i++){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderMagicNumber()==magic){
if(OrderType()==OP_BUY){
if( NormalizeDouble((Bid-OrderOpenPrice()),Digits)>=NormalizeDouble(BreakEven*point,Digits)){
if( (OrderStopLoss()-OrderOpenPrice())<0)
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+1*point,OrderTakeProfit(),0,Blue);
}
}else{
if( NormalizeDouble((OrderOpenPrice()-Ask),Digits)>=NormalizeDouble(BreakEven*point,Digits)){
if(((OrderOpenPrice()-OrderStopLoss())<0)||(OrderStopLoss()==0))
OrderModify(OrderTicket(),OrderOpenPrice()-1*point,OrderOpenPrice(),OrderTakeProfit(),0,Red);
Page 1 of 1 1

请登录后发表回复,如果你还没有账户你可以 免费注册

回到 通常讨论
menu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loader