Real author:
Mohammad Soubra
This is not a profitable EA.
This is just a basic/simple example for coders.
This example has been built using SAR (Stop And Reverse) indicator.
With Advanced Money Management function:
//+------------------------------------------------------------------+ // expert AdvancedMM function //+------------------------------------------------------------------+ double AdvancedMM() { int i; double AdvancedMMLots=0; bool profit1=false; int SystemHistoryOrders=0; for(i=0;i<OrdersHistoryTotal();i++) { bool ordsel = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); if(OrderMagicNumber()==MagicNumber) SystemHistoryOrders++; } bool profit2=false; int LO=0; if(SystemHistoryOrders<2) return(Lots); for(i=OrdersHistoryTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) if(OrderMagicNumber()==MagicNumber) { if(OrderProfit()>=0 && profit1) return(Lots); if(LO==0) { if(OrderProfit()>=0) profit1=true; if(OrderProfit()<0) return(OrderLots()); LO=1; } if(OrderProfit()>=0 && profit2) return(AdvancedMMLots); if(OrderProfit()>=0) profit2=true; if(OrderProfit()<0) { profit1=false; profit2=false; AdvancedMMLots+=OrderLots(); } } } return(AdvancedMMLots); }

Recommendations:
- Take Care!