MA.S.R_Trading_02

Author: FORTRADER.RU
Profit factor:
3011.46

This script is designed to automate trading on the MetaTrader platform based on moving average crossovers and recent high/low prices.

Here's a breakdown of what it does:

  1. Initialization: The script starts by defining variables and adjustable parameters like perma, maxi_per, and mini_per. These parameters control the sensitivity and timeframes used in calculations, respectively.

  2. Order Check: It checks if there are any existing buy or sell orders open. It keeps track of open BUY and SELL trades.

  3. Moving Average Calculation: It calculates three simple moving averages (SMAs) of closing prices, shifted by one, two, and three periods. These averages smooth out price fluctuations to identify trends.

  4. High/Low Price Detection: The script monitors for instances when moving averages cross each other. When the first MA is less then the second MA and the second MA is greater than the third MA, the script flags a potential SELL condition and records the highest price within a specified period (maxi_per). Conversely, When the first MA is greater then the second MA and the second MA is less than the third MA, the script flags a potential BUY condition and records the lowest price within a specified period (mini_per). These values are saved into the maximum and minimum arrays.

  5. Order Placement: Based on the moving average crossover and the lack of previous open orders it generates trading signals.

    • If the first moving average is less than the second, and the second is greater than the third, and there aren't any open SELL orders, the script will attempt to open a SELL order.
    • If the first moving average is greater than the second, and the second is less than the third, and there aren't any open BUY orders, the script will attempt to open a BUY order.
  6. Order Modification (Potential Stop Loss): The script iterates through all open orders and attempts to modify their stop loss levels based on the recently detected high or low prices.

    • If there's an open SELL order, it checks if the most recent high price is greater than the closing price from the last period. If so, it attempts to adjust the stop loss of the SELL order to the most recent high. If not it reduces the index.
    • If there's an open BUY order, it checks if the most recent low price is less than the closing price from the last period. If so, it attempts to adjust the stop loss of the BUY order to the most recent low. If not it reduces the index.

In essence, the script aims to identify potential entry points based on moving average crossovers and then manage risk by potentially setting or adjusting stop-loss orders based on recent price extremes. It continuously monitors and adjusts its actions based on price movements and the presence of existing orders.

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicator
19 Views
3 Downloads
0 Favorites
MA.S.R_Trading_02
//+------------------------------------------------------------------+
//|                                            MA.S.R_Trading_02.mq4 |
//|                                                     FORTRADER.RU |
//|                                          http://www.fortrader.ru |
//+------------------------------------------------------------------+
#property copyright "FORTRADER.RU"
#property link      "http://www.fortrader.ru"

double maximum[100000];
double minimum[100000];
int l,m,flopen,b,s,total,cnt,flopens;
extern int perma=5;
extern int maxi_per=5;
extern int mini_per=5;


int start()
  {
    total=OrdersTotal();
       b=0;s=0;
      for(cnt=0;cnt<total;cnt++)
         {
           OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
            if(OrderType()==OP_BUY)
            { b=1;}
          if(OrderType()==OP_SELL)
            { s=1;}
          }  
  /*--------------------------------------------------*/        
          
  
      double ma1=iMA(NULL,0,perma,0,MODE_SMA,PRICE_CLOSE,1);
      double ma2=iMA(NULL,0,perma,0,MODE_SMA,PRICE_CLOSE,2);
      double ma3=iMA(NULL,0,perma,0,MODE_SMA,PRICE_CLOSE,3);
      
      if(ma1<ma2 && ma2>ma3)
      {
      maximum[m]=High[iHighest(NULL,0,MODE_HIGH,maxi_per,1)];
      m++;  
      }
      
      if(ma1>ma2 && ma2<ma3)
      {
      minimum[l]=Low[iLowest(NULL,0,MODE_LOW,mini_per,1)];
      l++;  
      }
      
      if(ma1<ma2 && ma2>ma3 && s==0)
      {
      OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"",Green);
      }
      
       if(ma1>ma2 && ma2<ma3 && b==0)
      {
      OrderSend(Symbol(),OP_BUY,0.1,Bid,3,0,0,"",Red);
      }

      
         for(int cnt=0;cnt<OrdersTotal();cnt++)
        {
          OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
           if(OrderType()==OP_SELL)
           {
              if(maximum[m-1]>Close[1])
              {
              OrderModify(OrderTicket(),OrderOpenPrice(),maximum[m-1],0,0,Yellow);
              }
              else{m--;}
           }
              
           if(OrderType()==OP_BUY)
           {
              if(minimum[l-1]<Close[1])
              {
              OrderModify(OrderTicket(),OrderOpenPrice(),minimum[l-1],0,0,Yellow);
              }else{l--;} 
            }     
       }
        
   return(0);
}

Profitability Reports

EUR/USD Jul 2025 - Sep 2025
70671.78
Total Trades 444
Won Trades 310
Lost trades 134
Win Rate 69.82 %
Expected payoff 71466.62
Gross Profit 31731628.50
Gross Loss -449.00
Total Net Profit 31731179.50
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
22649.40
Total Trades 393
Won Trades 165
Lost trades 228
Win Rate 41.98 %
Expected payoff 40507.78
Gross Profit 15920262.00
Gross Loss -702.90
Total Net Profit 15919559.10
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
9.39
Total Trades 17
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 34.16
Gross Profit 649.90
Gross Loss -69.20
Total Net Profit 580.70
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
4.69
Total Trades 6
Won Trades 1
Lost trades 5
Win Rate 16.67 %
Expected payoff 25.57
Gross Profit 195.00
Gross Loss -41.60
Total Net Profit 153.40
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
3.33
Total Trades 128
Won Trades 6
Lost trades 122
Win Rate 4.69 %
Expected payoff 9.15
Gross Profit 1672.76
Gross Loss -501.63
Total Net Profit 1171.13
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
3.09
Total Trades 88
Won Trades 3
Lost trades 85
Win Rate 3.41 %
Expected payoff 7.49
Gross Profit 975.11
Gross Loss -316.05
Total Net Profit 659.06
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
2.86
Total Trades 144
Won Trades 6
Lost trades 138
Win Rate 4.17 %
Expected payoff 3.55
Gross Profit 785.50
Gross Loss -274.40
Total Net Profit 511.10
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
2.47
Total Trades 99
Won Trades 5
Lost trades 94
Win Rate 5.05 %
Expected payoff 5.88
Gross Profit 978.26
Gross Loss -396.04
Total Net Profit 582.22
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
2.04
Total Trades 158
Won Trades 5
Lost trades 153
Win Rate 3.16 %
Expected payoff 2.06
Gross Profit 640.40
Gross Loss -314.40
Total Net Profit 326.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.88
Total Trades 93
Won Trades 5
Lost trades 88
Win Rate 5.38 %
Expected payoff -0.49
Gross Profit 338.20
Gross Loss -383.80
Total Net Profit -45.60
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.75
Total Trades 128
Won Trades 7
Lost trades 121
Win Rate 5.47 %
Expected payoff -0.85
Gross Profit 325.66
Gross Loss -433.84
Total Net Profit -108.18
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.71
Total Trades 121
Won Trades 14
Lost trades 107
Win Rate 11.57 %
Expected payoff -0.89
Gross Profit 267.40
Gross Loss -375.30
Total Net Profit -107.90
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.66
Total Trades 105
Won Trades 5
Lost trades 100
Win Rate 4.76 %
Expected payoff -1.41
Gross Profit 293.05
Gross Loss -441.36
Total Net Profit -148.31
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.57
Total Trades 287
Won Trades 12
Lost trades 275
Win Rate 4.18 %
Expected payoff -1.74
Gross Profit 676.66
Gross Loss -1177.09
Total Net Profit -500.43
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.47
Total Trades 133
Won Trades 7
Lost trades 126
Win Rate 5.26 %
Expected payoff -2.48
Gross Profit 291.26
Gross Loss -620.93
Total Net Profit -329.67
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.32
Total Trades 389
Won Trades 15
Lost trades 374
Win Rate 3.86 %
Expected payoff -1.47
Gross Profit 267.30
Gross Loss -840.70
Total Net Profit -573.40
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.26
Total Trades 454
Won Trades 16
Lost trades 438
Win Rate 3.52 %
Expected payoff -1.66
Gross Profit 264.20
Gross Loss -1018.10
Total Net Profit -753.90
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.22
Total Trades 639
Won Trades 12
Lost trades 627
Win Rate 1.88 %
Expected payoff -2.42
Gross Profit 440.58
Gross Loss -1988.12
Total Net Profit -1547.54
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.20
Total Trades 236
Won Trades 5
Lost trades 231
Win Rate 2.12 %
Expected payoff -3.47
Gross Profit 201.57
Gross Loss -1020.16
Total Net Profit -818.59
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.19
Total Trades 260
Won Trades 14
Lost trades 246
Win Rate 5.38 %
Expected payoff -2.94
Gross Profit 177.20
Gross Loss -941.20
Total Net Profit -764.00
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.19
Total Trades 759
Won Trades 25
Lost trades 734
Win Rate 3.29 %
Expected payoff -5.07
Gross Profit 916.90
Gross Loss -4768.20
Total Net Profit -3851.30
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.18
Total Trades 651
Won Trades 14
Lost trades 637
Win Rate 2.15 %
Expected payoff -1.62
Gross Profit 235.50
Gross Loss -1290.40
Total Net Profit -1054.90
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.14
Total Trades 455
Won Trades 10
Lost trades 445
Win Rate 2.20 %
Expected payoff -1.83
Gross Profit 134.57
Gross Loss -966.49
Total Net Profit -831.92
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.13
Total Trades 199
Won Trades 4
Lost trades 195
Win Rate 2.01 %
Expected payoff -2.41
Gross Profit 72.36
Gross Loss -551.51
Total Net Profit -479.15
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.12
Total Trades 544
Won Trades 13
Lost trades 531
Win Rate 2.39 %
Expected payoff -9.57
Gross Profit 678.08
Gross Loss -5881.48
Total Net Profit -5203.40
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.09
Total Trades 486
Won Trades 7
Lost trades 479
Win Rate 1.44 %
Expected payoff -2.68
Gross Profit 129.40
Gross Loss -1431.80
Total Net Profit -1302.40
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.08
Total Trades 514
Won Trades 10
Lost trades 504
Win Rate 1.95 %
Expected payoff -8.05
Gross Profit 384.25
Gross Loss -4520.81
Total Net Profit -4136.56
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.03
Total Trades 545
Won Trades 5
Lost trades 540
Win Rate 0.92 %
Expected payoff -18.21
Gross Profit 276.30
Gross Loss -10199.61
Total Net Profit -9923.31
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.00
Total Trades 5
Won Trades 0
Lost trades 5
Win Rate 0.00 %
Expected payoff -119.09
Gross Profit 0.00
Gross Loss -595.45
Total Net Profit -595.45
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.00
Total Trades 251
Won Trades 11
Lost trades 240
Win Rate 4.38 %
Expected payoff -382.79
Gross Profit 296.50
Gross Loss -96376.90
Total Net Profit -96080.40
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 10
Won Trades 0
Lost trades 10
Win Rate 0.00 %
Expected payoff -10.21
Gross Profit 0.00
Gross Loss -102.08
Total Net Profit -102.08
-100%
-50%
0%
50%
100%

Comments