Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

SAR Automation Example - With Advanced Money Management - MetaTrader 4 Expert - MT4/MT5 Resources

author EAcpu | 4 reads | 0 comments |

Example of SAR Automated - with Advanced Money Management - expert for MetaTrader 4

Muhammad Subra

This is not a profitable EA.

This is just a basic/simple example for coders.

This example is built using the SAR (Stop and Reverse) indicator.

With advanced money management features:

 //+------------------------------------------------------------------+
// Expert AdvancedMM function
//+------------------------------------------------------------------+
Double advanced MM()
  {
integer i;
Double Premium MMLots= 0 ;
boolean profit1 = false ;
Integer system history order = 0 ;
  
for (i = 0 ;i< OrderHistoryTotal ();i++)
    {
boolean odsel = orderSelect (i, SELECT_BY_POS , MODE_HISTORY );
if ( OrderMagicNumber ()==MagicNumber) SystemHistoryOrders++;
    }
  
boolean profit2 = false ;
integer low = 0 ;
  
if (system history orders < 2 ) return (many);
for ( i = order history total () - 1 ; i >= 0 ; i - )
     {
if ( orderSelect (i, SELECT_BY_POS , MODE_HISTORY ))
if ( order magic number () == magic number)
          {
if ( order profit ()>= 0 && profit 1) return (many);
if (LO== 0 )
              {
if ( order profit ()>= 0 ) profit1= true ;
If ( Order Profit () < 0 ) return ( Order Batch ());
              low = 1 ;
              }
if ( Order Profit ()>= 0 && Profit2) return (Advanced MMLots);
if ( order profit ()>= 0 ) profit2= true ;
if ( order profit ()< 0 )
              {
              profit1= wrong ;
              profit2= wrong ;
              AdvancedMMLots+= OrderBatch ();
              }
          }
    }
return (AdvancedMMLots);
  } 

Example of SAR Automated - with Advanced Money Management - expert for MetaTrader 4

suggestion:


Attachment download

📎 sar-automated.mq4 (7.09 KB)

Source: MQL5 #15536

Verification code Refresh