MetaTrader5
Unlocking Proffessor v3: Your Go-To EA for MetaTrader 5
Author of the Idea: Vitaly
MQL5 Code Author: barabashkakvn
Let’s dive into the Proffessor v3 Expert Advisor (EA) for MetaTrader 5. This trading strategy is straightforward yet effective. You initiate a BUY or SELL position, and protect it with a pending Stop order set at a distance known as Delta 1. Next, a grid of Limit or Stop pending orders is created, spaced out by Delta 2. You can configure how many pending orders you want in each direction using the Max Lines setting. The pending orders—Buy Limit, Sell Limit, Buy Stop, and Sell Stop—are managed through a single PendingOrder function, which takes in the order type (order_type), volume (volume), stop loss (sl), and take profit (tp).
//+------------------------------------------------------------------+
//| Pending order |
//+------------------------------------------------------------------+
void PendingOrder(ENUM_ORDER_TYPE order_type,double volume,double price,double sl,double tp)
{
sl=m_symbol.NormalizePrice(sl);
tp=m_symbol.NormalizePrice(tp);
if(m_trade.OrderOpen(m_symbol.Name(),order_type,volume,0.0,
m_symbol.NormalizePrice(price),m_symbol.NormalizePrice(sl),m_symbol.NormalizePrice(tp)))
{
if(m_trade.ResultOrder()==0)
{
Print("#1 ",EnumToString(order_type)," -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResultTrade(m_trade,m_symbol);
}
else
{
Print("#2 ",EnumToString(order_type)," -> true. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResultTrade(m_trade,m_symbol);
}
}
else
{
Print("#3 ",EnumToString(order_type)," -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
PrintResultTrade(m_trade,m_symbol);
}
//---
}
Once you hit the Profit Close target, it’s time to close all positions and wipe out any pending orders. On the flip side, if you find yourself losing more than the set Loss Close (which can be disabled by setting it to 0.0), you can also close all positions and delete the pending orders.
The EA’s operations—opening positions and setting protective pending orders—are executed within a designated time frame, from Start Hour to End Hour. The Start Hour can be less than, equal to, or even exceed the End Hour.
Main Idea
The core of this EA is its analysis of the ADX value on the Work TimeFrame. When the ADX falls below 40, it signals a flat market, prompting the placement of Limit pending orders. If the ADX is above 40, Stop pending orders take precedence.
If the DI+ is higher than DI-, the EA goes for a buy; otherwise, it opts for a sell.
The optimal settings for the two parameters are: Current Bar ADX ranging from 0 to 2 (with a step of 1), and Work TimeFrame set from M1 to H1.
For EURUSD, with Current Bar ADX at 0 and Work TimeFrame set to H1:
For USDJPY, with Current Bar ADX at 2 and Work TimeFrame set to M1:
When working with EURUSD, if the Current Bar ADX is 0 and Loss Close is set to "0.0":
And for USDJPY, with Current Bar ADX at 2 and Loss Close also set to "0.0":
2018.10.26