Today, let's dive into a powerful trading system designed for both long and short trades, using the ColorSchaffJCCXTrendCycle indicator. This system operates within a single Expert Advisor (EA) and offers the flexibility to adjust trade volumes based on your previous results. Sounds intriguing, right? Let's break it down!
Understanding the Input Parameters
We can categorize the input parameters into two main groups:
- L_ for long position management.
- S_ for short position management.
//+----------------------------------------------+ //| Input parameters for long trades | //+----------------------------------------------+ magic numberinput uint L_Magic=777; //L magic number //+----------------------------------------------+ //| Input parameters for short trades | //+----------------------------------------------+ input uint S_Magic=555; //S magic number
Each trading system operates independently with its own magic number. In the unpredictable world of trading, different parameters are often required for bullish and bearish markets. To get your EA set up correctly, I recommend testing one trading system at a time by disabling the other using the relevant switches.
input bool L_PosOpen=true; //L permission to enter long positions input bool L_PosClose=true; //L permission to exit long positions
Once you've configured the first system, you can repeat the setup for the second.
Managing Trade Volume
The EA also includes inputs to manage the trade volumes of open positions:
input uint L_TotalMMTriger=5; //L number of last Buy deals for stop loss calculation input uint L_LossMMTriger=3 //L number of losing Buy deals to reduce MM input double L_SmallMM=0.01 //L deposit share in a deal in case of loss input double L_MM=0.1 //L deposit share in a deal during normal trading input MarginMode L_MMMode=LOT; //L lot setting mode
And for the short trades:
input uint S_TotalMMTriger=5 //S number of last Sell deals for stop loss calculation input uint S_LossMMTriger=3 //S number of losing Sell deals to reduce MM input double S_SmallMM=0.01 //S deposit share in a deal in case of loss input double S_MM=0.1 //S deposit share in a deal during normal trading input MarginMode S_MMMode=LOT; //S lot setting mode
With these settings, if you have three losing trades out of the last five, the EA will open the next trade in the same direction at a volume of 0.01 lots. If not, it will trade at 0.1 lots.
To get the EA running smoothly, make sure you have the compiled JCCX.ex5 and ColorSchaffJCCXTrendCycle.ex5 indicator files in your <terminal_data_directory>\MQL5\Indicators.
Test Results
The following tests used the default input parameters. Notably, we didn't use Stop Loss or Take Profit during these tests.

Trading examples with symmetrical settings
Here are the testing results for GBPUSD on an H8 timeframe for the year 2017:

Testing results chart

Trading examples with non-symmetrical settings
Related Posts
- Unlock Your Trading Potential with the Fundamental Trader EA for MetaTrader 4
- Creating an Expert Advisor for Dark Cloud Cover and Piercing Line Patterns with CCI Confirmation
- Mastering the Exp_ColorSchaffJCCXTrendCycle EA for MetaTrader 5
- Harnessing MQL5 Wizard for Trading Signals: 3 Black Crows & 3 White Soldiers with MFI
- RRS Impulse: Your Go-To Scalping EA for MetaTrader 4