Overview
This prompt provides a code snippet for a trading algorithm, aimed at programmers and traders interested in automated trading strategies. It benefits those looking to enhance their trading systems with advanced risk management and AI integration.
Prompt Overview
Purpose: This Expert Advisor aims to combine Smart Money Concepts with AI for effective trading strategies.
Audience: It is designed for traders and developers interested in automated trading solutions in the financial markets.
Distinctive Feature: The integration of AI confirmation with traditional market analysis enhances decision-making in trading.
Outcome: Users can expect improved trading performance through advanced risk management and strategic entry points.
Quick Specs
- Media: Text
- Use case: Generation
- Techniques: Few-Shot Prompting, Output Constraints, Prompt Templates
- Models: ChatGPT, Claude, Gemini AI
- Estimated time: 5-10 minutes
- Skill level: Beginner
Variables to Fill
- [None, Low, Medium, High] – None, Low, Medium, High
- [0] – 0
Example Variables Block
- [None, Low, Medium, High]: Example None, Low, Medium, High
- [0]: Example 0
The Prompt
“`mql5
//+——————————————————————+
//| Expert Advisor: Aivex-Lumina Fusion AI |
//| Strategy: Combines Smart Money Concepts with AI Confirmation |
//+——————————————————————+
#include
#include
CTrade trade;
//— Input parameters
input ENUM_TIMEFRAMES EntryTF = PERIOD_M15;
input ENUM_TIMEFRAMES TrendTF = PERIOD_H4;
input double RiskPercent = 1.0;
input double ATRMultiplier = 1.5;
input int ATRPeriod = 14;
input int TrendMAPeriod = 50;
input bool UseNewsFilter = true;
input bool UseATRStop = true;
input bool EnableLondonNY = true;
input bool EnablePatternAI = true;
//— New Input parameters
input int MaxOpenTrades = 5; // Maximum number of open trades
input double MaxLotSize = 1.0; // Maximum lot size per trade
//— Risk mode
enum RiskMode [None, Low, Medium, High];
input RiskMode risk_mode = Low;
//— Global variables
datetime lastTradeTime = 0;
int tradesToday = 0;
//— Indicator handles
int atrHandle;
double atrValue[];
int maHandle;
double trendMA[];
//+——————————————————————+
//| Structure Analysis Functions |
//+——————————————————————+
bool MarketStructureShiftDetected()
{
double high1 = iHigh(_Symbol, EntryTF, 1);
double high2 = iHigh(_Symbol, EntryTF, 2);
double low1 = iLow(_Symbol, EntryTF, 1);
double low2 = iLow(_Symbol, EntryTF, 2);
return ((high1 > high2 && low1 > low2) || (high1 < high2 && low1 < low2)); } bool PriceSweptLiquidity() { double high = iHigh(_Symbol, EntryTF, 1); double prevHigh = iHigh(_Symbol, EntryTF, 2); double low = iLow(_Symbol, EntryTF, 1); double prevLow = iLow(_Symbol, EntryTF, 2); return (high > prevHigh || low < prevLow); } bool OrderBlockPresent() { double bodySize = MathAbs(iClose(_Symbol, EntryTF, 1) - iOpen(_Symbol, EntryTF, 1)); double wickSize = MathAbs(iHigh(_Symbol, EntryTF, 1) - iLow(_Symbol, EntryTF, 1)) - bodySize; return (bodySize > wickSize * 2);
}
bool TrendAligned()
{
if (CopyBuffer(maHandle, 0, 0, 1, trendMA) trendMA[0]);
}
bool VolatilitySafe()
{
return (atrValue[0] > 0);
}
bool PatternAIConfirmed()
{
if (!EnablePatternAI) return true;
double close0 = iClose(_Symbol, EntryTF, 0);
double close1 = iClose(_Symbol, EntryTF, 1);
double close2 = iClose(_Symbol, EntryTF, 2);
return (close1 < close2 && close0 > close1); // Example pattern: bullish reversal
}
bool InTradingSession()
{
if (!EnableLondonNY) return true;
datetime time = TimeCurrent();
MqlDateTime dt;
TimeToStruct(time, dt);
int hour = dt.hour;
return (hour >= 8 && hour = 13 && hour = MaxOpenTrades) return;
for (int i = 0; i < GetTradeCount(); i++) { if (TrendAligned() && iClose(_Symbol, EntryTF, 1) > iOpen(_Symbol, EntryTF, 1))
trade.Buy(lot, _Symbol, 0, iClose(_Symbol, EntryTF, 0) – sl, iClose(_Symbol, EntryTF, 0) + tp, “FusionAI Buy”);
else if (!TrendAligned() && iClose(_Symbol, EntryTF, 1) < iOpen(_Symbol, EntryTF, 1)) trade.Sell(lot, _Symbol, 0, iClose(_Symbol, EntryTF, 0) + sl, iClose(_Symbol, EntryTF, 0) - tp, "FusionAI Sell"); } lastTradeTime = TimeCurrent(); tradesToday++; } int GetTradeCount() { switch (risk_mode) { case Low: return 1; case Medium: return 3; case High: return 5; default: return 0; } } // New function to get the current number of open trades int GetCurrentOpenTrades() { int total = 0; for (int i = 0; i < PositionsTotal(); i++) { if (PositionGetSymbol(i) == _Symbol) total++; } return total; } double CalculateLotSize(double slPoints) { double risk = AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100.0; double tickValue; if (!SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE, tickValue)) tickValue = 1.0; double lotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP); double contractSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_CONTRACT_SIZE); double lots = (risk / (slPoints * tickValue / _Point)) / contractSize; // Cap the lot size to not exceed MaxLotSize return NormalizeDouble(MathMin(lots, MaxLotSize), 2); } //+------------------------------------------------------------------+ //| Expert Initialization | //+------------------------------------------------------------------+ int OnInit() { atrHandle = iATR(_Symbol, EntryTF, ATRPeriod); maHandle = iMA(_Symbol, TrendTF, TrendMAPeriod, 0, MODE_EMA, PRICE_CLOSE); ArraySetAsSeries(trendMA, true); ArraySetAsSeries(atrValue, true); return INIT_SUCCEEDED; } //+------------------------------------------------------------------+ //| Expert Tick | //+------------------------------------------------------------------+ void OnTick() { if (TimeCurrent() - lastTradeTime < 60) return; if (!InTradingSession()) return; if (CopyBuffer(atrHandle, 0, 0, 1, atrValue) [/prompt_box]
Screenshot Examples
How to Use This Prompt
- [EntryTF]: Timeframe for entry signals.
- [TrendTF]: Timeframe for trend analysis.
- [RiskPercent]: Percentage of account risk per trade.
- [MaxOpenTrades]: Maximum allowable open trades.
- [ATRMultiplier]: Multiplier for ATR-based stop loss.
- [TrendMAPeriod]: Period for moving average trend indicator.
- [UseNewsFilter]: Toggle for news event filtering.
- [EnablePatternAI]: Toggle for AI pattern confirmation.
Tips for Best Results
- Optimize Entry Conditions: Ensure your entry logic is robust by validating multiple indicators before executing trades.
- Manage Risk Effectively: Use the risk percentage wisely to determine lot sizes and avoid over-leveraging your account.
- Implement News Filters: Consider using news filters to avoid trading during high-impact news events that can cause volatility.
- Monitor Open Trades: Regularly check the number of open trades to adhere to your maximum limit and adjust your strategy accordingly.
FAQ
- What is the purpose of the Aivex-Lumina Fusion AI?
It combines Smart Money Concepts with AI confirmation for trading strategies. - What does the ATRMultiplier parameter do?
It adjusts the stop loss and take profit based on the Average True Range. - How does the Expert Advisor handle maximum trades?
It limits the number of open trades based on the MaxOpenTrades parameter. - What is the function of the TrendAligned check?
It ensures trades align with the current market trend using moving averages.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


