MA.S.R_Trading

Author: FORTRADER.RU
Profit factor:
3339.20

Trading System Logic Overview: MA.S.R_Trading

This document provides a non-technical explanation of the logic contained within the MA.S.R_Trading.mq4 script. The script is designed to automate trading by identifying momentum shifts in price trends and managing active positions based on historical price extremes.

1. Market Analysis Logic

The script monitors the market using a Moving Average (MA), which is a calculation that smooths out price data to identify the general direction of the trend. It specifically looks at the relationship between three consecutive points of this moving average to determine "peaks" and "valleys":

  • Bearish Reversal Detection: The script checks if the current moving average is lower than the previous one, while the previous one was higher than the one before it. This identifies a downward "hook" or peak in the trend.
  • Bullish Reversal Detection: The script checks if the current moving average is higher than the previous one, while the previous one was lower than the one before it. This identifies an upward "hook" or valley in the trend.

2. Entry Rules (Execution)

The script automatically opens trades based on the signals identified above, provided that a position of the opposite type does not already exist:

  • Sell Orders: If a bearish reversal is detected and there are no active Sell positions, the script opens a Sell trade.
  • Buy Orders: If a bullish reversal is detected and there are no active Buy positions, the script opens a Buy trade.

3. Dynamic Price Tracking

Whenever a reversal signal occurs, the script captures specific price data:

  • For Bearish signals, it identifies the highest price reached within the last 10 candles.
  • For Bullish signals, it identifies the lowest price reached within the last 10 candles.

These values are stored in a memory list (an array) to serve as dynamic benchmarks for managing open trades.

4. Trade Management and Modification

Once a trade is open, the script continuously monitors the market to adjust the trade's "Stop Loss" or exit target based on the historical data it collected during the entry phase:

  • For Sell Positions: The script looks at the most recent high price recorded. If the current market price stays below that high, it updates the trade's parameters to that high price.
  • For Buy Positions: The script looks at the most recent low price recorded. If the current market price stays above that low, it updates the trade's parameters to that low price.

If the market price moves past these historical benchmarks in a way that violates the logic, the script discards the old benchmark and looks to the next available one in its memory list.

Summary of Behavior

The script acts as a momentum-reversal trader. It waits for the moving average to "turn around" to enter a trade. Once inside a trade, it uses the highest or lowest points from the immediate past to set a dynamic exit point, effectively attempting to lock in gains or limit losses based on recent price extremes.

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
14 Views
1 Downloads
0 Favorites
MA.S.R_Trading
//+------------------------------------------------------------------+
//|                                               MA.S.R_Trading.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;


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,10,1)];
      m++;  
      }
      
      if(ma1>ma2 && ma2<ma3)
      {
      minimum[l]=Low[iLowest(NULL,0,MODE_LOW,10,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
77498.83
Total Trades 426
Won Trades 367
Lost trades 59
Win Rate 86.15 %
Expected payoff 89086.12
Gross Profit 37951177.00
Gross Loss -489.70
Total Net Profit 37950687.30
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
25966.45
Total Trades 311
Won Trades 164
Lost trades 147
Win Rate 52.73 %
Expected payoff 51187.84
Gross Profit 15920030.90
Gross Loss -613.10
Total Net Profit 15919417.80
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
14.36
Total Trades 8
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 72.96
Gross Profit 627.40
Gross Loss -43.70
Total Net Profit 583.70
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
13.35
Total Trades 6
Won Trades 3
Lost trades 3
Win Rate 50.00 %
Expected payoff 97.95
Gross Profit 635.30
Gross Loss -47.60
Total Net Profit 587.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%
GBP/USD Oct 2024 - Jan 2025
3.68
Total Trades 103
Won Trades 5
Lost trades 98
Win Rate 4.85 %
Expected payoff 5.47
Gross Profit 774.10
Gross Loss -210.60
Total Net Profit 563.50
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
3.68
Total Trades 137
Won Trades 4
Lost trades 133
Win Rate 2.92 %
Expected payoff 9.02
Gross Profit 1696.71
Gross Loss -461.46
Total Net Profit 1235.25
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
2.11
Total Trades 101
Won Trades 3
Lost trades 98
Win Rate 2.97 %
Expected payoff 4.67
Gross Profit 895.20
Gross Loss -423.73
Total Net Profit 471.47
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
1.43
Total Trades 197
Won Trades 7
Lost trades 190
Win Rate 3.55 %
Expected payoff 1.99
Gross Profit 1303.08
Gross Loss -911.41
Total Net Profit 391.67
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.02
Total Trades 93
Won Trades 14
Lost trades 79
Win Rate 15.05 %
Expected payoff 0.10
Gross Profit 498.00
Gross Loss -488.76
Total Net Profit 9.24
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.01
Total Trades 47
Won Trades 5
Lost trades 42
Win Rate 10.64 %
Expected payoff 0.05
Gross Profit 315.10
Gross Loss -312.60
Total Net Profit 2.50
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.58
Total Trades 98
Won Trades 4
Lost trades 94
Win Rate 4.08 %
Expected payoff -2.18
Gross Profit 289.28
Gross Loss -502.50
Total Net Profit -213.22
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.52
Total Trades 132
Won Trades 7
Lost trades 125
Win Rate 5.30 %
Expected payoff -2.39
Gross Profit 348.06
Gross Loss -663.26
Total Net Profit -315.20
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.52
Total Trades 264
Won Trades 7
Lost trades 257
Win Rate 2.65 %
Expected payoff -1.95
Gross Profit 552.87
Gross Loss -1068.57
Total Net Profit -515.70
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.39
Total Trades 191
Won Trades 9
Lost trades 182
Win Rate 4.71 %
Expected payoff -4.22
Gross Profit 521.03
Gross Loss -1327.61
Total Net Profit -806.58
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.32
Total Trades 491
Won Trades 14
Lost trades 477
Win Rate 2.85 %
Expected payoff -2.44
Gross Profit 558.69
Gross Loss -1757.19
Total Net Profit -1198.50
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.31
Total Trades 258
Won Trades 17
Lost trades 241
Win Rate 6.59 %
Expected payoff -3.19
Gross Profit 370.10
Gross Loss -1192.60
Total Net Profit -822.50
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.30
Total Trades 112
Won Trades 8
Lost trades 104
Win Rate 7.14 %
Expected payoff -2.82
Gross Profit 135.00
Gross Loss -450.70
Total Net Profit -315.70
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.26
Total Trades 466
Won Trades 21
Lost trades 445
Win Rate 4.51 %
Expected payoff -6.07
Gross Profit 986.30
Gross Loss -3814.10
Total Net Profit -2827.80
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.24
Total Trades 507
Won Trades 13
Lost trades 494
Win Rate 2.56 %
Expected payoff -1.60
Gross Profit 259.70
Gross Loss -1070.90
Total Net Profit -811.20
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.23
Total Trades 349
Won Trades 13
Lost trades 336
Win Rate 3.72 %
Expected payoff -1.95
Gross Profit 206.40
Gross Loss -888.50
Total Net Profit -682.10
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.18
Total Trades 214
Won Trades 12
Lost trades 202
Win Rate 5.61 %
Expected payoff -4.38
Gross Profit 209.20
Gross Loss -1147.30
Total Net Profit -938.10
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.15
Total Trades 254
Won Trades 3
Lost trades 251
Win Rate 1.18 %
Expected payoff -3.44
Gross Profit 157.99
Gross Loss -1030.53
Total Net Profit -872.54
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.15
Total Trades 318
Won Trades 8
Lost trades 310
Win Rate 2.52 %
Expected payoff -2.02
Gross Profit 109.73
Gross Loss -751.24
Total Net Profit -641.51
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.12
Total Trades 287
Won Trades 7
Lost trades 280
Win Rate 2.44 %
Expected payoff -8.24
Gross Profit 318.89
Gross Loss -2683.27
Total Net Profit -2364.38
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.09
Total Trades 421
Won Trades 6
Lost trades 415
Win Rate 1.43 %
Expected payoff -2.69
Gross Profit 115.70
Gross Loss -1248.00
Total Net Profit -1132.30
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.08
Total Trades 133
Won Trades 3
Lost trades 130
Win Rate 2.26 %
Expected payoff -3.54
Gross Profit 39.20
Gross Loss -510.21
Total Net Profit -471.01
-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.05
Gross Profit 0.00
Gross Loss -595.25
Total Net Profit -595.25
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.00
Total Trades 91
Won Trades 7
Lost trades 84
Win Rate 7.69 %
Expected payoff -1052.18
Gross Profit 275.70
Gross Loss -96023.70
Total Net Profit -95748.00
-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%
GBP/CAD Oct 2025 - Feb 2026
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 220.56
Gross Profit 220.56
Gross Loss 0.00
Total Net Profit 220.56
-100%
-50%
0%
50%
100%

Comments