Author: Testing
Profit factor:
1.91

Okay, here's a breakdown of what this program does, written for someone who doesn't know how to code.

In Simple Terms: What is this program trying to do?

This program is designed to automatically trade on the financial markets (like currencies) using a trading platform called MetaTrader. It's like a robot that looks at price charts and tries to make decisions about when to buy ("go long") or sell ("go short") based on a few simple rules.

Here's how it works:

  1. Moving Averages: The program uses several "Moving Averages" (MAs). A moving average is like a line that smooths out the price data over a certain period. For example, a 10-day moving average calculates the average price over the last 10 days. The program uses four of these, each with a different period (10, 20, 50, and 200) giving different perspectives of the markets behavior.

  2. Setup: When the program starts, it reads a few settings defined as inputs. These settings determine how the program will behave. The parameters configure period lengths of the MAs (MA1period, MA2period, MA3period, MA4period), the type of calculation for these moving averages (MA1mode, MA2mode, MA3mode, MA4mode), and other parameters for managing the trading strategy.

  3. Checking for Trades:

    • First, it checks if it has already made a trade. It figures this out by looking at the trades it has already placed.
    • If it is already in a trade, it checks to see if the price behavior justifies closing the position. It then closes the trade if certain conditions based on a comparison between some of the moving averages are met.
    • If it's not already in a trade, the program looks for new opportunities to buy or sell.
  4. Finding Opportunities (New Signals):

    • The program uses the moving averages to determine if it should buy or sell. Here's the basic idea:
      • Buy (Long) Signal: If the shorter moving averages are above the longer moving averages (e.g., 10-day MA > 20-day MA > 50-day MA > 200-day MA), it indicates an upward trend, and the program will attempt to buy.
      • Sell (Short) Signal: If the shorter moving averages are below the longer moving averages (e.g., 10-day MA < 20-day MA < 50-day MA < 200-day MA), it indicates a downward trend, and the program will attempt to sell.
  5. Money Management (Risk):

    • The program can automatically decide how much to invest on each trade based on the size of the account and a risk setting.
    • It allows you to specify a fixed lot size or use a money management system that adjusts the lot size based on the account balance and risk level.
  6. Placing Orders:

    • If the program finds a buy or sell signal, it will automatically place an order with the broker (the company that executes the trades).
  7. Order closing: The program will close the positions when MA1 and MA2 cross based on the selections of CloseMA_A and CloseMA_B parameters.

Key Things to Remember:

  • Automated Trading: This program makes trades automatically without any human intervention (once it's running).
  • Risk: Automated trading involves risk. The program can lose money if the market moves in the wrong direction.
  • Moving Averages are Indicators: The moving averages are just one way to analyze the market. There are many other indicators and strategies that traders use. This program uses this as its main indication to buy or sell.

In short: The program is a simple trading robot that uses moving averages to identify potential buying and selling opportunities and automatically places trades based on those signals. It also includes some basic money management features to control risk.

Price Data Components
Series array that contains tick volumes of each bar
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Moving average indicator
Miscellaneous
It issuies visual alerts to the screen
12 Views
1 Downloads
0 Favorites
Longterm_a
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                              TrendScalper_TR.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Testing"
#property link      "http://www.metaquotes.net/"

//---- input parameters
extern int       MA1period=10;
extern int       MA1mode=1;
extern int       MA2period=20;
extern int       MA2mode=1;
extern int       MA3period=50;
extern int       MA3mode=1;
extern int       MA4period=200;
extern int       MA4mode=1;
extern int       CloseMA_A=2;
extern int       CloseMA_B=3;
extern double    LotsIfNoMM=0.1;
extern int       Stoploss=0;
extern int       TakeProfit=0;
extern int       Slip=5;
extern int       MM_Mode=0;
extern int       MM_Risk=40;

double Opentrades,orders,first,mode,Ilo,sym,b;
double b4signal,Signal,Triggerline,b4Triggerline,Nowsignal,NowTriggerline,sl,LastOpByExpert,LastBarChecked;
int cnt,cnt2,OpenPosition,notouchbar; 
bool test;
double MA1,MA2,MA3,MA4,CloseMA1,CloseMA2;

#define Long 1
#define Short 2

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }


//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//return(0);
   
   if ( ! IsTesting() ) Comment(" Trailingstop    ",  b, "\n","      Tick no. ", iVolume(NULL,0,0),"\n"," Lots    ",Ilo);


   /**********************************Money and Risk Management***************************************
   Changing the value of mm will give you several money management options
   mm = 0 : Single 1 lot orders.
   mm = -1 : Fractional lots/ balance X the risk factor.(use for Mini accts)
   mm = 1 : Full lots/ balance X the risk factor up to 100 lot orders.(use for Regular accounts)
   ***************************************************************************************************
   RISK FACTOR:
   risk can be anything from 1 up. 
   Factor of 5 adds a lot for every $20,000.00 added to the balance. 
   Factor of 10 adds a lot with every $10.000.00 added to the balance.
   The higher the risk,  the easier it is to blow your margin..
   **************************************************************************************************/

   if (MM_Mode < 0)  {
   Ilo = MathCeil(AccountBalance()*MM_Risk/10000)/10;
     if (Ilo > 100) {  
     Ilo = 100;  
     }
   } else {
   Ilo = LotsIfNoMM;
   }
   if (MM_Mode > 0)  
    {
   Ilo = MathCeil(AccountBalance()*MM_Risk/10000)/10;
    if (Ilo > 1)  
    {
    Ilo = MathCeil(Ilo);
    }
    if (Ilo < 1)  
    {
    Ilo = 1;
    }
    if (Ilo > 100)  
    {  
     Ilo = 100;  
     }
   }
 	      

//     if (notouchbar == Time[0]) 
//         return(0);


     if (LastBarChecked == Time[0]) 
     //if (1 == 2) //just so this part is never true for now
         return(0); 
      else 
  	      {
  	      LastBarChecked = Time[0]; 

         MA1=iMA(NULL,0,MA1period,0,MA1mode,PRICE_CLOSE,1);
         MA2=iMA(NULL,0,MA2period,0,MA2mode,PRICE_CLOSE,1);
         MA3=iMA(NULL,0,MA3period,0,MA3mode,PRICE_CLOSE,1);
         MA4=iMA(NULL,0,MA4period,0,MA4mode,PRICE_CLOSE,1);
           	     
         switch (CloseMA_A)
            {
            case 1:
               CloseMA1=MA1;
               break;
            case 2:
               CloseMA1=MA2;
               break;
            case 3:
               CloseMA1=MA3;
               break;
            case 4:
               CloseMA1=MA4;
               break;
            default:
               Alert("CloseMA_A must be in range 1-4");
               break;
            }
            
         switch (CloseMA_B)
            {
            case 1:
               CloseMA2=MA1;
               break;
            case 2:
               CloseMA2=MA2;
               break;
            case 3:
               CloseMA2=MA3;
               break;
            case 4:
               CloseMA2=MA4;
               break;
            default:
               Alert("CloseMA_B must be in range 1-4");
               break;
            }
            
            
                       	      
         Opentrades=0;
         for (cnt=0;cnt<OrdersTotal();cnt++) 
            {
            if ( OrderSelect (cnt, SELECT_BY_POS) == false )  continue;
            if ( OrderSymbol()==Symbol()) 
               {
               Opentrades=Opentrades+1;
               if(OrderType()==OP_BUY) 
                  {
                  OpenPosition = Long; 

                  if (IsTesting()) 
                     {
                        //LastLogTime=iTime(NULL,PERIOD_H1,1);
                        if (OrderTakeProfit()==OrderOpenPrice()+Point*10000)
                           OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice()+Point*10001,0,Cyan);
                          else
                           OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice()+Point*10000,0,Cyan);
                     }

                  }
                 else 
                  {
                  OpenPosition = Short; 

                  if (IsTesting()) 
                     {
                        //LastLogTime=iTime(NULL,PERIOD_H1,1);
                        if (OrderTakeProfit()==0)
                           OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),Point*1,0,Cyan);
                          else
                           OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),0,0,Cyan);
                     }

                  }
                  
               }
            }

  	      
  	      
         //----------------------------------------Order Control-------------------------------------------
 
         if (Opentrades != 0)  
   
            {


            if (OpenPosition == Long)
               {
               if (CloseMA1<CloseMA2)
                  {
                  OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Red);
                  //Alert("DanMA close long ",Symbol());
                  //notouchbar=Time[0];
                  return(0);
                  }
               }
            
            if (OpenPosition == Short)
               {
               if (CloseMA1>CloseMA2)
                  {
                  OrderClose(OrderTicket(),OrderLots(),Ask,Slip,Red);
                  //Alert("DanMA close short ",Symbol());
                  //notouchbar=Time[0];
                  return(0);
                  }
               }
            

            }

  	      
  	      
         //----------------------------------------New signals-------------------------------------------
         
         
         if (Opentrades == 0)  
   
           {
           if (MA1>MA2 && MA2 > MA3 && MA3>MA4)
                  {
                  OrderSend(Symbol(),OP_BUY,Ilo,Ask,Slip,0,0,"",0,0,White);
                  return(0);
                  }
           
           if (MA1<MA2 && MA2 < MA3 && MA3<MA4)
                  {
                     OrderSend(Symbol(),OP_SELL,Ilo,Bid,Slip,0,0,"",0,0,Red);
                     //notouchbar=Time[0];
                     return(0);
                  }
           
           
           
           
           }
           
  	      
  	      
  	      
      } //Ends if (LastBarChecked == Time[0])

   return(0);
  }


Profitability Reports

EUR/USD Jan 2025 - Jul 2025
35.70
Total Trades 73
Won Trades 51
Lost trades 22
Win Rate 69.86 %
Expected payoff 480.88
Gross Profit 36116.10
Gross Loss -1011.60
Total Net Profit 35104.50
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
1.87
Total Trades 29
Won Trades 10
Lost trades 19
Win Rate 34.48 %
Expected payoff 21.54
Gross Profit 1340.27
Gross Loss -715.75
Total Net Profit 624.52
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.30
Total Trades 14
Won Trades 6
Lost trades 8
Win Rate 42.86 %
Expected payoff 8.21
Gross Profit 491.75
Gross Loss -376.83
Total Net Profit 114.92
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
1.26
Total Trades 17
Won Trades 6
Lost trades 11
Win Rate 35.29 %
Expected payoff 5.37
Gross Profit 438.46
Gross Loss -347.25
Total Net Profit 91.21
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
1.25
Total Trades 14
Won Trades 5
Lost trades 9
Win Rate 35.71 %
Expected payoff 2.01
Gross Profit 142.05
Gross Loss -113.88
Total Net Profit 28.17
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
1.24
Total Trades 17
Won Trades 8
Lost trades 9
Win Rate 47.06 %
Expected payoff 5.44
Gross Profit 473.90
Gross Loss -381.50
Total Net Profit 92.40
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.22
Total Trades 26
Won Trades 10
Lost trades 16
Win Rate 38.46 %
Expected payoff 4.39
Gross Profit 633.90
Gross Loss -519.70
Total Net Profit 114.20
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
1.20
Total Trades 49
Won Trades 14
Lost trades 35
Win Rate 28.57 %
Expected payoff 5.09
Gross Profit 1471.00
Gross Loss -1221.50
Total Net Profit 249.50
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.14
Total Trades 33
Won Trades 14
Lost trades 19
Win Rate 42.42 %
Expected payoff 3.92
Gross Profit 1080.07
Gross Loss -950.72
Total Net Profit 129.35
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.10
Total Trades 38
Won Trades 11
Lost trades 27
Win Rate 28.95 %
Expected payoff 2.99
Gross Profit 1244.23
Gross Loss -1130.50
Total Net Profit 113.73
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
1.05
Total Trades 16
Won Trades 7
Lost trades 9
Win Rate 43.75 %
Expected payoff 1.74
Gross Profit 601.10
Gross Loss -573.20
Total Net Profit 27.90
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
1.04
Total Trades 17
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 1.15
Gross Profit 478.90
Gross Loss -459.40
Total Net Profit 19.50
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.01
Total Trades 31
Won Trades 10
Lost trades 21
Win Rate 32.26 %
Expected payoff 0.20
Gross Profit 562.18
Gross Loss -555.99
Total Net Profit 6.19
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.00
Total Trades 17
Won Trades 6
Lost trades 11
Win Rate 35.29 %
Expected payoff -0.10
Gross Profit 504.10
Gross Loss -505.80
Total Net Profit -1.70
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.97
Total Trades 29
Won Trades 11
Lost trades 18
Win Rate 37.93 %
Expected payoff -0.30
Gross Profit 276.88
Gross Loss -285.47
Total Net Profit -8.59
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.79
Total Trades 43
Won Trades 11
Lost trades 32
Win Rate 25.58 %
Expected payoff -8.21
Gross Profit 1351.30
Gross Loss -1704.30
Total Net Profit -353.00
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.75
Total Trades 42
Won Trades 13
Lost trades 29
Win Rate 30.95 %
Expected payoff -5.51
Gross Profit 686.47
Gross Loss -917.82
Total Net Profit -231.35
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.71
Total Trades 16
Won Trades 5
Lost trades 11
Win Rate 31.25 %
Expected payoff -4.62
Gross Profit 182.90
Gross Loss -256.80
Total Net Profit -73.90
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.68
Total Trades 19
Won Trades 6
Lost trades 13
Win Rate 31.58 %
Expected payoff -4.93
Gross Profit 198.50
Gross Loss -292.10
Total Net Profit -93.60
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.62
Total Trades 33
Won Trades 11
Lost trades 22
Win Rate 33.33 %
Expected payoff -4.72
Gross Profit 253.00
Gross Loss -408.80
Total Net Profit -155.80
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.61
Total Trades 17
Won Trades 5
Lost trades 12
Win Rate 29.41 %
Expected payoff -11.06
Gross Profit 288.52
Gross Loss -476.62
Total Net Profit -188.10
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.60
Total Trades 36
Won Trades 12
Lost trades 24
Win Rate 33.33 %
Expected payoff -4.85
Gross Profit 266.80
Gross Loss -441.50
Total Net Profit -174.70
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.49
Total Trades 35
Won Trades 5
Lost trades 30
Win Rate 14.29 %
Expected payoff -15.18
Gross Profit 510.23
Gross Loss -1041.39
Total Net Profit -531.16
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.47
Total Trades 44
Won Trades 11
Lost trades 33
Win Rate 25.00 %
Expected payoff -12.85
Gross Profit 510.90
Gross Loss -1076.20
Total Net Profit -565.30
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.38
Total Trades 39
Won Trades 10
Lost trades 29
Win Rate 25.64 %
Expected payoff -14.67
Gross Profit 357.43
Gross Loss -929.55
Total Net Profit -572.12
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.35
Total Trades 21
Won Trades 5
Lost trades 16
Win Rate 23.81 %
Expected payoff -19.22
Gross Profit 220.73
Gross Loss -624.39
Total Net Profit -403.66
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.24
Total Trades 46
Won Trades 5
Lost trades 41
Win Rate 10.87 %
Expected payoff -16.41
Gross Profit 243.40
Gross Loss -998.19
Total Net Profit -754.79
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.16
Total Trades 22
Won Trades 4
Lost trades 18
Win Rate 18.18 %
Expected payoff -27.53
Gross Profit 116.60
Gross Loss -722.37
Total Net Profit -605.77
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -35087.23
Gross Profit 0.00
Gross Loss -105261.70
Total Net Profit -105261.70
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 6
Won Trades 0
Lost trades 6
Win Rate 0.00 %
Expected payoff -17604.67
Gross Profit 0.00
Gross Loss -105628.00
Total Net Profit -105628.00
-100%
-50%
0%
50%
100%

Comments