Base for a working EA - The Quadrant.

 

Introduction

...

From my quite extensive experience in the FX market, there were many ups and downs periods. The Forex market is indeed a complex market with all the terminology and leverage, but later on I have realized it is a very good cash cow business. 

I have gone through many strategies, research papers and used many. And I am a firm believer that each and every strategy ever created in the world works, we just gotta fine tune and connect it with the best suitable asset class and in the best environment possible.

After countless strategies, right now I am working on automating each and every strategy that I like and works into algos... in this process I have learned many important lessons that I would love to share with others. 

This article will solely focus on the Major 4 factors that I find very important and must treat it as an important base for building an EA. 

The parts of the Quadrant are:

1) Win Rate (WR)

2) Drawdown (DD)

3) Risk to Reward Ratio (RR)

4) Trade Frequency 

Connecting the 4 factors

...

Let us connect the 4 parts of the Quadrant.

1) WR

Win Rate (WR) is a percentage of your total trades that results in profit. For example if you traded total of 100 trades in one month and 73 of them were closed in profit (regardless of the dollar value), your WR would be 73%.


2) DD

Drawdown is basically the % lowest point your equity has fallen from the peak equity that you have. If your first position goes down to 4% and it later recovers back to your direction, the statistics will catch the DD to be 4%.


3) RR

Risk to Reward Ratio measures the potential profit of a trade relative to its potential loss. In basic terms, if your SL dollar value is $10 and your TP is $20, you are risking $10 to potentially make $20. 

4) Trade Frequency 

Trade frequency is the number of trades open within the set certain period of time. If you backtest a strategy for 1 year, and the trade count is 500...and as FX market on average works 24/5, 5*4 = 20 days on average per month (averaging out without consideration of public and bank holidays)... so per year, 20*12 = 240 days, the algo system trades 500 trades/240 days = 2 trades/day... this is the trade frequency. 


Now connecting these 4 factors


As I observed other EAs and tried automating my own strategies... for a HEALTHY EA to be profitable, this seems to be the basic/foundational formula: ROI of EA = WR + RR + DD + Trade Frequency. 


Scenario 1:

Suppose the EA has 90%+WR; from what I have observed RR will be compromised.... rarely do we see in retail places that an EA has 90% WR and maintains a minimum of 1:1 RR (not saying there are not, but I haven't found one realistically yet). 90% of the time if the trades are closing in profit, Risk to Reward will be tight, as Risk is normalized but the Reward is bare minimum so the TP is hit more often than regular. Moreover, in this scenario there will be large number of small wins, but one loss will destroy more than half of the wins. 

In this scenario the DD will also be less, and the equity graph will be quite some time of smooth growth and one moment of sudden downfall and then back again to smooth growth... and cycle goes on and on. 

Trade frequency is also crucial.. in whole year if the EA has only taken 10 trades and 9 of them are profitable, the statistics or history report from your broker will show you have the WR of 90% 


Scenario 2:

Suppose the EA has 25% WR but has enormous RR of around 1:5, one trade will make up for your three trades and even some more. The factor of this scenario is that your DD will be high... if you have multiple consecutive losses, the chances of your equity being eroded are pretty high. 

If the Trade frequency is pretty less, the system being right once is a while will eventually cancel out the losses and the equity graph will be slow down slopes with sudden upward spikes. But a huge problem of this scenario is that the account might get blown first before even making a single profit as many numbers of consecutive losses will Drawdown the equity to such extent that the regular lot size position might not be able to open as lack of sufficient fund, that way that one winning trade probability also drops. 


From these two scenarios, what I want the readers to know is that making a healthy EA, the trader/developer must understand the importance of balance between these 4 factors of the quadrant. BALANCE is the key. 


These two scenarios can show in table data like this:

WR RR DD Trade Frequency


Even with basic permutation and combination of these 4 factors:

P(4,1)+P(4,2)+P(4,3)+P(4,4)=4+12+24+24=64.


And if we assign with up and down arrows for increment and decrement of the factors with each other this the table that we get:


WR RR DD Trade Frequency

After the discussion of two basic scenarios, let us dive deep by using an EA with basic logic and I will tune the RR in various scenarios and how it is going to impact the DD and WR while keeping the trade frequency ceteris paribus, and ultimately the ROI. 

Here is a simple SMA crossover EA that I will be testing on XAUUSD, 15 min timeframe from Jan 1,2026 till July 7, 2026.

EA Code: 

//+------------------------------------------------------------------+
//|                                             XAUUSD_CrossOver.mq5 |
//|                                                      Basic SMA EA|
//+------------------------------------------------------------------+
#property copyright "FinExcel"
#property link      "https://www.mql5.com"
#property version   "1.00"

#include <Trade\Trade.mqh>

input double InpLotSize    = 0.01;
input int    InpFastSMA    = 9;
input int    InpSlowSMA    = 21;
input int    InpStopLoss   = 500;
input int    InpTakeProfit = 1000;
input int    InpMagicNumber = 123456;

CTrade         trade;
int            fastSmaHandle;
int            slowSmaHandle;
double         fastSmaBuffer[];
double         slowSmaBuffer[];

int OnInit()
  {
   trade.SetExpertMagicNumber(InpMagicNumber);
   
   ArraySetAsSeries(fastSmaBuffer, true);
   ArraySetAsSeries(slowSmaBuffer, true);

   fastSmaHandle = iMA(_Symbol, _Period, InpFastSMA, 0, MODE_SMA, PRICE_CLOSE);
   slowSmaHandle = iMA(_Symbol, _Period, InpSlowSMA, 0, MODE_SMA, PRICE_CLOSE);

   if(fastSmaHandle == INVALID_HANDLE || slowSmaHandle == INVALID_HANDLE)
     {
      return(INIT_FAILED);
     }

   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
   IndicatorRelease(fastSmaHandle);
   IndicatorRelease(slowSmaHandle);
  }

void OnTick()
  {
   for(int i = PositionsTotal() - 1; i >= 0; i--)
     {
      if(PositionGetSymbol(i) == _Symbol)
        {
         long magic = PositionGetInteger(POSITION_MAGIC);
         if(magic == InpMagicNumber)
            return;
        }
     }

   if(CopyBuffer(fastSmaHandle, 0, 0, 3, fastSmaBuffer) <= 0) return;
   if(CopyBuffer(slowSmaHandle, 0, 0, 3, slowSmaBuffer) <= 0) return;

   bool buySignal = (fastSmaBuffer[2] <= slowSmaBuffer[2]) && (fastSmaBuffer[1] > slowSmaBuffer[1]);
   bool sellSignal = (fastSmaBuffer[2] >= slowSmaBuffer[2]) && (fastSmaBuffer[1] < slowSmaBuffer[1]);

   double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);

   if(buySignal)
     {
      double sl = 0, tp = 0;
      if(InpStopLoss > 0) sl = ask - (InpStopLoss * point);
      if(InpTakeProfit > 0) tp = ask + (InpTakeProfit * point);
         
      trade.Buy(InpLotSize, _Symbol, ask, sl, tp, "SMA Buy");
     }
   else if(sellSignal)
     {
      double sl = 0, tp = 0;
      if(InpStopLoss > 0) sl = bid + (InpStopLoss * point);
      if(InpTakeProfit > 0) tp = bid - (InpTakeProfit * point);
         
      trade.Sell(InpLotSize, _Symbol, bid, sl, tp, "SMA Sell");
     }
  }

Basically this is using 9 SMA and 21 SMA, and here is the backtest result... focus on the factors that we are discussing in this article... WR, RR, DD and Trade Frequency:

OP1

Here our WR is 33.46%, DD is 49.6% and our Average Profit Trade is $10.50 and $5.52 is our Average Loss Trade, so basically our RR is 1:1.9, we have a great RR but our ROI is ultimately in negative... basically -36%

OP2


Now, I will change the InpStopLoss and InpTakeProfit level to higher number to give them more breathing room. 

And here is the backtest result after the input changes:


Here we can see that the negative ROI has changed by a huge margin...WR has jumped to 42.2% from 33.46% and DD decreased to 37.66% from 49.6%, but a critical thing we must analyze is that the RR has been jumbled up. It is just now approx. 1:1.4, from this two back test I want to show how the same logic, has different result when we just tune the RR part... heavily impacting the WR and DD and ultimately the ROI. 

Input codes: 

input double InpLotSize    = 0.01;
input int    InpFastSMA    = 9;
input int    InpSlowSMA    = 21;
input int    InpStopLoss   = 500;
input int    InpTakeProfit = 1000;
input int    InpMagicNumber = 123456;

Just the InptStoploss and InptTakeProfit was changed. The logic remained the same of 9 SMA and 21 SMA crossover. I have attached the mq5 file of this simple logic EA, you can backtest and try working around by adding filters, indicators and such. 

In the sequence of tuning the RR differently, the results were quite different. From both the backtest result we can clearly see that we do not have a clear winning logic/strategy for the XAUUSD 15min timeframe. But we were able to lower down the loss to some extent. 

The above 2 backtest were done in this environment:


Now let us move to connecting one with the other factor.

WR vs RR:

These two factors are the most common associative part in any strategy, algo or EA. It is also known as one of the classic Trade-Off phenomenon. I am sharing my experience on this part, after testing many of EAs, and my strategies... it is nearly impossible on retail level to have both high WR and superior RR in a single strategy... for example, 80-90% with 1:4-1:5RR. At least till now I haven't found any strategy that has this results with significant compromise on DD and Trade Frequency. 

If one wants to drastically increase the WR, you gotta exit earlier at a very lower Take Profit(TP) level so that more and more of your trade will be closed in profit, that way making them closer and closer to the entry price and making it hard for the strategy to have less losses the strategy also have to maintain the Stop Loss (SL) further and further way. This way is the basic way to increase the WR but RR will surely plummet. 

In the other hand, when you are trying to make a very very logical RR as possible, like have 1:3 or 1:4...if your logic is not the finest and the strongest the WR will inevitably drop to less that 50% or even lower. That way even if you are right, it will take a longer time to achieve the superior RR, and if the entry logic is perfect but there is no guarantee that your position will move smoothly in the direction without sudden pullback or unforeseen news/volatility. 


Impact of WR and RR on the DD:

These two factors have a major role on determining the strategy DD. For example, if the system relies on 1:4RR but only wins 25% of the time, it is mathematically guaranteed to face long streaks of consecutive losses. Eventually the system can be profitable but the losing streak can cause a massive, prolonged DD on the equity curve. 

Another example that I have seen in many of high scalping EAs is that there is literally 90%+ WR that the system is producing in backtesting as well as in real live trading test, the RR is extremely terrible...it is risking certain high for example 20:1RR or 10:1 RR, but it is clearly visible that these system with this WR and RR will have equity curve going straight up and the visible DD will be near zero for long time period. However, the remaining 10% risk probability hits harder sooner or later creating a massive dent on the DD, and if there are 2 or more consecutive losses, DD and Margin-Level is pushed hard. 


Trade Frequency vs WR:

This is very very important... as in data science we need a really good and healthy level of real sample data. Trade Frequency is like a lever, it can tilt to the very low and very high level and from my experience it must be where the strategy is, and we must measure on the basis of the strategy type. 

If the system is a scalper, we have to expect a higher frequency, higher trade count. For scalping system I try to average out on the basis of day. If the Trade Frequency is like 1000/day. I am not touching that scalping system, for me it is way too much and might fall into high frequency trading where retail infrastructure might not be able to support it at all. 

If the system is a intraday, I try to average out on the basis of month. As Forex Market is 24/5, we get about 20 trading days on average without counting the bank holidays and public holidays. So I do not expect to have a trade every single day, on average 15-20 trades/month is good enough for me. Some day there can be 2 trades per day but followed by no trades for 2 days, it is good enough. 

So understanding the balance between proper trade frequency and understanding the type of system is very important so that we get the correct amount of sample data, both in backtest and real account live testing, further more this interconnectivity must aware the trader/developer to stop forcing to create almost (I said 'almost') an impossible system that which has High WR, High RR, Low DD, High Trade Frequency. Looking to create a balanced system having a 'sweet spot' between these basic four factors will be a right and healthier approach in building a system that will last a long time. Not exactly sacrifice but the trader/ developer must balance out one factor to certain extent to promote the remaining three factor. 


One of my favorite personal combination:

Personally I have come to an agreement with myself that I cannot, as a retail trader/developer build a strategy/algo that will have the best nature of these 4 factors that will be durable for 2-5 years continuously. 

This is my top favorite combination = High WR, Low-Normal RR(I am fine with minimum 1:1RR), Low DD, High Trade Frequency. 

I really want to keep my DD very very low, as minimized as possible. Why? Because at backtest we get some approximately clear DD that we can expect, when we test it on a real live account the actual DD will be near to it although we must accept that past result won't perfectly determine the future results. If DD is low on backtest report and forward test report, so at any near point of time we start the system on real account we won't be largely impacted by the consecutive losses in case we have them at the beginning of our live testing. 

From my experience achieving the high RR like 1:4 and 1:5 without volatility and noise in the duration of a position being opened is really rare, FX is a volatile market always changing there will be moments where winners can turn into losers. I prefer consistency over frequent sudden jumps and falls on the equity curve. 


Conclusion

...

The trader/developer who understands the balance with these 4 factors with each other will get an advantageous start in the process of building a working EA, working in a sense we can say profitable. Many of us might be attracted to the high 90% WR, but the health of RR should be also matched... if a system has 90% WR with 1:1RR minimum, no doubt it is profitable... but that system makes 10 trades per year, it won't be enough data so that the EA is healthy as when market dynamics changes that system won't be giving out these attractive numbers. 

Numbers is the thing, playing with them and finding the region that you want to be can be very beneficial, as I told you there are many combinations and permutations; most of them will be a profitable system/strategy but what works for your time, personal finance, patience. Connecting the trader/developer mindset with the foundation of these 4 factors, the QUADRANT, will be the basic for creating an edge for oneself and one's trading journey. 

Files: