0% found this document useful (0 votes)
37 views4 pages

Ultra Insinct 1.0 Universal

The document describes the ULTRA INSTINCT EA 1.0, a trading algorithm for MT4 and MT5 that employs an EMA and RSI strategy with dynamic risk management. It includes input parameters for risk percentage, take profit, stop loss, and maximum open trades, along with functions for initialization, chart styling, trade logic, and drawing tools. The EA aims to automate trading decisions based on technical indicators and market conditions.

Uploaded by

siphosethu760
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

Ultra Insinct 1.0 Universal

The document describes the ULTRA INSTINCT EA 1.0, a trading algorithm for MT4 and MT5 that employs an EMA and RSI strategy with dynamic risk management. It includes input parameters for risk percentage, take profit, stop loss, and maximum open trades, along with functions for initialization, chart styling, trade logic, and drawing tools. The EA aims to automate trading decisions based on technical indicators and market conditions.

Uploaded by

siphosethu760
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

//+------------------------------------------------------------------+

//| ULTRA INSTINCT EA 1.0 - Universal (MT4 + MT5) |


//| Strategy: EMA 50/190 + RSI with Dynamic Risk Management |
//+------------------------------------------------------------------+
#property strict

#if defined(__MQL5__)
#property version "1.1"
#property script_show_inputs
#else
#property copyright "ULTRA INSTINCT EA MT4 + MT5"
#endif

//--- Input Parameters


input double RiskPercent = 2.0; // % of equity to risk per trade
input int TakeProfitPips = 100; // Take profit (pips)
input int StopLossPips = 30; // Stop loss (pips)
input int MaxOpenTrades = 50; // Max trades at a time

color COLOR_TRENDLINE = clrDeepSkyBlue;


color COLOR_SR_ZONE = clrBlue;
color COLOR_DS_ZONE = clrDodgerBlue;

//+------------------------------------------------------------------+
//| Initialization Function |
//+------------------------------------------------------------------+
int OnInit()
{
StyleChart();
Print("Ultra Instinct EA Initialized");
return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Chart Styling |
//+------------------------------------------------------------------+
void StyleChart()
{
#ifdef __MQL5__
ChartSetInteger(0, CHART_COLOR_BACKGROUND, 0, clrNavy);
ChartSetInteger(0, CHART_COLOR_FOREGROUND, 0, clrWhite);
ChartSetInteger(0, CHART_COLOR_CANDLE_BULL, 0, clrSkyBlue);
ChartSetInteger(0, CHART_COLOR_CANDLE_BEAR, 0, clrRed);
ChartSetInteger(0, CHART_COLOR_GRID, 0, clrBlack);
ChartSetInteger(0, CHART_COLOR_CHART_UP, 0, clrDeepSkyBlue);
ChartSetInteger(0, CHART_COLOR_CHART_DOWN, 0, clrRed);
#endif
}

//+------------------------------------------------------------------+
//| Tick Handler |
//+------------------------------------------------------------------+
void OnTick()
{
if (CountOpenTrades() >= MaxOpenTrades)
return;

DetectTrendLines();
DetectSupportResistance();
DetectDemandSupply();

CheckTradeConditions();
}

//+------------------------------------------------------------------+
//| Count Trades |
//+------------------------------------------------------------------+
int CountOpenTrades()
{
int count = 0;
#ifdef __MQL5__
count = PositionsTotal();
#else
for (int i = 0; i < OrdersTotal(); i++)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
count++;
#endif
return count;
}

//+------------------------------------------------------------------+
//| Trade Logic |
//+------------------------------------------------------------------+
void CheckTradeConditions()
{
double ema50 = iMA(_Symbol, 0, 50, 0, MODE_EMA, PRICE_CLOSE, 0);
double ema190 = iMA(_Symbol, 0, 190, 0, MODE_EMA, PRICE_CLOSE, 0);
double rsi = iRSI(_Symbol, 0, 14, PRICE_CLOSE, 0);

if (ema50 > ema190 && rsi < 60)


{
double lotSize = CalculateLotSize();
double price = Ask;
double sl = price - StopLossPips * _Point;
double tp = price + TakeProfitPips * _Point;

#ifdef __MQL5__
MqlTradeRequest req;
MqlTradeResult res;
ZeroMemory(req);
req.action = TRADE_ACTION_DEAL;
req.symbol = _Symbol;
req.volume = lotSize;
req.type = ORDER_TYPE_BUY;
req.price = price;
req.sl = NormalizeDouble(sl, _Digits);
req.tp = NormalizeDouble(tp, _Digits);
req.deviation = 10;
req.magic = 123456;
OrderSend(req, res);
#else
OrderSend(_Symbol, OP_BUY, lotSize, price, 10,
sl, tp, "Ultra Instinct", 123456, 0, clrBlue);
#endif
}
}

//+------------------------------------------------------------------+
//| Risk-based Lot Size Calculation |
//+------------------------------------------------------------------+
double CalculateLotSize()
{
double riskAmount;
double slInPoints = StopLossPips * _Point;
double lot = 0.01;
#ifdef __MQL5__
double equity = AccountInfoDouble(ACCOUNT_EQUITY);
riskAmount = equity * RiskPercent / 100.0;
double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
if (tickValue > 0 && slInPoints > 0)
lot = NormalizeDouble(riskAmount / (slInPoints / _Point * tickValue), 2);
#else
double equity = AccountEquity();
riskAmount = equity * RiskPercent / 100.0;
double tickValue = MarketInfo(_Symbol, MODE_TICKVALUE);
if (tickValue > 0 && slInPoints > 0)
lot = NormalizeDouble(riskAmount / (slInPoints / _Point * tickValue), 2);
#endif
return MathMax(lot, 0.01);
}

//+------------------------------------------------------------------+
//| Drawing Tools |
//+------------------------------------------------------------------+
void DetectTrendLines()
{
string name = "TrendLine_1";
if (ObjectFind(0, name) < 0)
{
ObjectCreate(0, name, OBJ_TREND, 0, Time[10], High[10], Time[0], Low[0]);
ObjectSetInteger(0, name, OBJPROP_COLOR, COLOR_TRENDLINE);
}
}

void DetectSupportResistance()
{
DrawSRZone("SupportZone", iLow(_Symbol, 0, 10), COLOR_SR_ZONE);
DrawSRZone("ResistanceZone", iHigh(_Symbol, 0, 10), COLOR_SR_ZONE);
}

void DrawSRZone(string name, double price, color c)


{
if (ObjectFind(0, name) < 0)
{
ObjectCreate(0, name, OBJ_HLINE, 0, TimeCurrent(), price);
ObjectSetInteger(0, name, OBJPROP_COLOR, c);
}
}

void DetectDemandSupply()
{
DrawRectangle("DemandZone", iLow(_Symbol, 0, 20), iLow(_Symbol, 0, 20) + 20 *
_Point, COLOR_DS_ZONE);
DrawRectangle("SupplyZone", iHigh(_Symbol, 0, 20) - 20 * _Point, iHigh(_Symbol,
0, 20), COLOR_DS_ZONE);
}
void DrawRectangle(string name, double p1, double p2, color c)
{
if (ObjectFind(0, name) < 0)
{
ObjectCreate(0, name, OBJ_RECTANGLE, 0, Time[30], p1, Time[0], p2);
ObjectSetInteger(0, name, OBJPROP_COLOR, c);
ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_DOT);
ObjectSetInteger(0, name, OBJPROP_BACK, true);
}
}

You might also like