/*[[ Name := fnProfitSqueeze Author := Copyright © 2005, iExpertAdvisor, LLC Link := http://www.iExpertAdvisor.com Notes := UserFunction designed to sqeeze every last PIP from a profitable trade. ]]*/ input: Profit1(0); input: TrailAfterProfit1(0); input: Profit2(0); input: TrailAfterProfit2(0); input: Profit3(0); input: TrailAfterProfit3(0); input: Profit4(0); input: TrailAfterProfit4(0); vars: MinProfit(0), TrailAfterProfit(0); var: cnt(0); for cnt=1 to TotalTrades begin if( Ord(cnt,VAL_SYMBOL) == Symbol ) then { // Trade has hit our min profit, we are not going to give it up MinProfit=0; if( (Ord(cnt,VAL_PROFIT) >= (Profit1)) and (Profit1 != 0) ) then {MinProfit=Profit1;TrailAfterProfit=TrailAfterProfit1;}; if( (Ord(cnt,VAL_PROFIT) >= (Profit2)) and (Profit2 != 0) ) then {MinProfit=Profit2;TrailAfterProfit=TrailAfterProfit2;}; if( (Ord(cnt,VAL_PROFIT) >= (Profit3)) and (Profit3 != 0) ) then {MinProfit=Profit3;TrailAfterProfit=TrailAfterProfit3;}; if( (Ord(cnt,VAL_PROFIT) >= (Profit4)) and (Profit4 != 0) ) then {MinProfit=Profit4;TrailAfterProfit=TrailAfterProfit4;}; if( (Ord(cnt,VAL_PROFIT) >= (MinProfit)) and (MinProfit != 0) ) then { if ( Ord(cnt,VAL_TYPE) == OP_BUY ) then { if( Ord(cnt,VAL_STOPLOSS) < (Bid-(TrailAfterProfit*Point)) ) then { Print("Long: stop moved(+): ", (Bid-(TrailAfterProfit*Point)), " PROFIT=", Ord(cnt,VAL_PROFIT), " MinProfit=", MinProfit ); ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Bid-(TrailAfterProfit*Point),Ord(cnt,VAL_TAKEPROFIT),Red); return(0); }; }; // end BUY if ( Ord(cnt,VAL_TYPE) == OP_SELL ) then { if( Ord(cnt,VAL_STOPLOSS) > (Ask+(TrailAfterProfit*Point)) ) then { Print("Short: stop moved(+): ", (Ask+(TrailAfterProfit*Point)), " PROFIT=", Ord(cnt,VAL_PROFIT), " MinProfit=", MinProfit ); ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),Ask+(TrailAfterProfit*Point),Ord(cnt,VAL_TAKEPROFIT),Red); return(0); }; }; // end SELL }; // end min }; end; return(0);