//+------------------------------------------------------------------+ //| Exp-4StepStop.mq4 | //| Copyright © 2006, LeonSi. | //| http://www.expert-mt4.nm.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, LeonSi." #property link "http://www.expert-mt4.nm.ru" //---- input parameters extern int Trailing1=50; extern int STLos1=20; extern int Trailing2=40; extern int STLos2=40; extern int Trailing3=30; extern int STLos3=60; extern int Trailing4=10; extern int STLos4=90; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- int cnt; //---- Go for Change StopLoss if(OrdersTotal()>0) { Comment(" "); for(cnt=0; cnt<=OrdersTotal(); cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); //---- StopLoss for Buy if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderStopLoss()>0) { if(OrderOpenPrice()+(STLos4*Point)<Bid && OrderStopLoss()<Bid-(Trailing4*Point)) { Comment("4 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket()); OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Trailing4*Point),OrderTakeProfit(),0,Blue); return(0); } //---- STLos1 if(OrderOpenPrice()+(STLos3*Point)<Bid && OrderStopLoss()<Bid-(Trailing3*Point)) { Comment("3 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket()); OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Trailing3*Point),OrderTakeProfit(),0,Blue); return(0); } //---- STLos2 if(OrderOpenPrice()+(STLos2*Point)<Bid && OrderStopLoss()<Bid-(Trailing2*Point)) { Comment("2 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket()); OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Trailing2*Point),OrderTakeProfit(),0,Blue); return(0); } //---- STLos3 if(OrderOpenPrice()+(STLos1*Point)<Bid && OrderStopLoss()<Bid-(Trailing1*Point)) { Comment("1 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket()); OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Trailing1*Point),OrderTakeProfit(),0,Blue); return(0); } } //---- StopLoss for Sell if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderStopLoss()>0) { if(OrderOpenPrice()-(STLos4*Point)>Ask && OrderStopLoss()>Ask+(Trailing4*Point)) { Comment("4 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket()); OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Trailing4*Point),OrderTakeProfit(),0,Green); return(0); } //---- STLos1 if(OrderOpenPrice()-(STLos3*Point)>Ask && OrderStopLoss()>Ask+(Trailing3*Point)) { Comment("3 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket()); OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Trailing3*Point),OrderTakeProfit(),0,Green); return(0); } //---- STLos2 if(OrderOpenPrice()-(STLos2*Point)>Ask && OrderStopLoss()>Ask+(Trailing2*Point)) { Comment("2 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket()); OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Trailing2*Point),OrderTakeProfit(),0,Green); return(0); } //---- STLos3 if(OrderOpenPrice()-(STLos1*Point)>Ask && OrderStopLoss()>Ask+(Trailing1*Point)) { Comment("1 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket()); OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Trailing1*Point),OrderTakeProfit(),0,Green); return(0); } } } } //+------------------------------------------------------------------+ return(0); }
Sample
Analysis
Market Information Used:
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Checks for the total of open orders
It can change open orders parameters, due to possible stepping strategy
Other Features: