//+------------------------------------------------------------------+ //| FXPT_RemoveAllStops.mq4 | //| Developed by fxprotrader | //| http://www.fxpro-trader.com" | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, fxprotrader" #property link "http://www.fxpro-trader.com" //-------- HISTORY---------------- // v0.1 Initial release(012412) //-------------------------------- #property show_confirm double Poin; //+------------------------------------------------------------------+ //| Custom initialization function | //+------------------------------------------------------------------+ int init(){ if (Point == 0.00001) Poin = 0.0001; else { if (Point == 0.001) Poin = 0.01; else Poin = Point; } return(0); } //+------------------------------------------------------------------+ //| script to remove all stops | //+------------------------------------------------------------------+ int start(){ int i,type,err,Slippage=3; double price; bool result; string CommentField; double StopLoss,TakeProfit,SL,TP; //---- for(i=OrdersTotal()-1;i>=0;i--){ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ type=OrderType(); if(OrderSymbol()==Symbol()){ double ask = MarketInfo(Symbol(), MODE_ASK); double bid = MarketInfo(Symbol(), MODE_BID); double prc = 0; StopLoss=MathAbs(OrderOpenPrice()-OrderStopLoss())/Poin; TakeProfit=MathAbs(OrderOpenPrice()-OrderTakeProfit())/Poin; if (OrderType() == OP_BUY) prc = bid; else prc=ask; CommentField=OrderComment(); while(true){ if(type==OP_BUY){ SL=prc+(StopLoss*Poin); TP=prc-(TakeProfit*Poin); result=OrderSend(Symbol(),OP_SELL,OrderLots(),Bid,3,SL,TP,CommentField,999,0,Red); } //sell else{ SL=prc+(StopLoss*Poin); TP=prc-(TakeProfit*Poin); result=OrderSend(Symbol(),OP_BUY,OrderLots(),Bid,3,SL,TP,CommentField,999,0,Blue); } if(result!=true) {err=GetLastError(); Print("LastError = ",err);} else err=0; if(err==135) RefreshRates(); else break; } } }//if sym else Print( "When selecting a trade, error ",GetLastError()," occurred"); } if(err==0){ Alert("All Stop Losses have been successfully Removed"); } return(0); } //+------------------------------------------------------------------+