Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Trading on Retail Sentiment - MetaTrader 4 Expert | MT4 EA Download - MetaTrader 4 Resources

author EAcpu | 6 reads | 0 comments |

Trade By Retail Sentiment - expert for MetaTrader 4

Trade By Retail Sentiment - expert for MetaTrader 4

Trade By Retail Sentiment - expert for MetaTrader 4

Trade By Retail Sentiment - expert for MetaTrader 4

Trade By Retail Sentiment - expert for MetaTrader 4

Trade By Retail Sentiment - expert for MetaTrader 4

This Expert Advisor (EA) utilizes retail trader sentiment in the Ziwox API, combined with simple technical filters to make inverse trading decisions. The idea is simple: if most retail traders are long, we consider selling, and if most retail traders are short, we consider buying. By combining sentiment analysis with moving average trend confirmation, EAs provide an intelligent trading approach based on collective market behavior.

Code and implementation are from this MQL5 article

Why retail sentiment matters:

Retail trader sentiment reflects the positions and biases of small traders in the market. It’s no secret that retail traders often make poor judgments on market movements due to emotional trading, poor risk management, or overreaction to news. By analyzing the long-short ratio of retail investors, we can pursue a contrarian strategy that tends to align with institutional flows and broader market trends.

Sentiment analysis can help traders:

Identify overextended market conditions.

Identify potential reversals early.

Enhance technical analysis with behavioral insights.

Reduce risk by avoiding crowded trades.

How EA works:

This EA retrieves retail sentiment data via the Ziwox API and combines it with a moving average cross filter:

API integration:
Using the GetAPI function, the EA sends a web request to the Ziwox endpoint to obtain sentiment data in JSON format. The data includes key fields such as retail long ratio, retail short ratio, and risk sentiment. Then use JsonDataParse to parse the JSON into an array (APIJSON).

Reverse logic:

If the retail long ratio >= 60% and the fast MA is higher than the slow MA, the EA will consider a sell trade.

If the retail short ratio >= 60% and the fast MA is below the slow MA, the EA will consider a buy trade.
This ensures that trades are counter to retail sentiment but still in line with technical trend confirmations.

Technology filter:
Simple Moving Average (iMA) filter trades with user-defined periods (shortMAPeriod and longMAPeriod). Only execute trades that are in line with the moving average trend.

Automated trading:
When AutoTrade is enabled, the EA automatically opens orders, checks for new candles via IsNewCandle(), and uses OrdersTotal() to ensure there are no duplicate trades.

Visualization:
The EA uses DrawSentiment and ButtonCreate to draw sentiment indicators on the chart, displaying retail long and short ratios in a clear color-coding manner. Green indicates long positions and red indicates short positions.

Key code components explained:

GetAPI: Handles API calls to Ziwox, manages rate limits, retries and saves data to a JSON file.

JsonDataParse: Reads a JSON file, parses sentiment values, and stores them in an APIJSON array for use by trading logic.

OnTick: Checks the conditions for each price tick, applies reverse logic using the MA trend filter, and sends an order when the conditions are met.

DrawSentiment and ButtonCreate: Visualize sentiment directly on MT4 charts for instant insights.

IsNewCandle: Ensures that transactions are only checked once per new candle to avoid multiple executions on the same candle.

Instructions for use:

Place the EA into the Experts folder of MT4.

Enter your Ziwox API key in the APIKey field.

Adjust shortMAPeriod and longMAPeriod as needed.

If you want fully automated trading, set AutoTrade to true.

Load the EA onto any symbol chart. It will capture sentiments, visualize them, and trade based on contrarian strategies.

This EA combines behavioral financial insights from retail investor sentiment with technical analysis to provide a simple yet effective contrarian trading strategy. By monitoring the collective bias of retail traders, the system helps identify potential market reversals and avoid crowded trades, giving disciplined traders an advantage.


Attachment download

📎 TradeBySentiment.mq4 (29.04 KB)

📎 JAson.mqh (30.59 KB)

Source: MQL5 #62627

Trading on Retail Sentiment - MetaTrader 4 Expert Preliminary Tips

This page has been supplemented with structured instructions, focusing on the purpose of EA source code, MQL4/MQL5 platform compatibility, testing process and risk control. Before downloading or deploying, it is recommended to first determine whether it is consistent with your own variety, cycle and account environment.

Suitable for who to use

  • Users who want to quickly screen EA source code and are willing to do simulation disk verification first.
  • People who need to compare MT4/MT5 EAs, indicators, scripts or source code projects.
  • Traders who wish to record backtests, parameters and risk boundaries before placing a trade.

Testing and risk control suggestions

  • First verify the default parameters in the strategy tester or demo account, and then adjust the symbol, period, spread and trading period one by one.
  • Scalping, grid, martin, and high-frequency strategies should focus on observing maximum drawdowns, consecutive losses, slippage, and trading frequency.
  • It is not recommended to run any document directly on the real disk. At least observe the simulated disk performance for 2-4 weeks first.

FAQ

Can MT4 and MT5 be used interchangeably?
Usually cannot be used directly. EX4/MQ4 corresponds to MT4, EX5/MQ5 corresponds to MT5, and the source code needs to be compiled in the corresponding MetaEditor.

Is this resource guaranteed to be profitable?
cannot. EAs, indicators and scripts can only be used as trading tools, and the results depend on parameters, market environment, spreads, slippage and risk control.

What else can I continue to watch?
Forex EA download , foreign exchange indicator download , EA evaluation , MQL5 CodeBase .

English Search Notes

This page is also optimized for English search intent around Trading by Retail Sentiment - MetaTrader 4 Expert . Related search terms include: MQL4 source code, MQL5 source code. Test any Forex EA, Expert Advisor, MT4/MT5 indicator, script or MQL source code with historical data and a demo account before live trading.

Verification code Refresh