Vizion-Trading-EA/Experts/carterv1.mq5
2026-02-19 23:19:25 -06:00

627 lines
No EOL
43 KiB
MQL5

//+------------------------------------------------------------------+
//| QuarterTheory_VIZION_ULTRA_v3.1.mq5 |
//| ULTRA AGGRESSIVE | NO LIMITS | ALL SETUPS ALL THE TIME |
//| Every Tick Entry | 300 Rule | Unlimited Trades |
//+------------------------------------------------------------------+
#property copyright "QuarterTheory x VIZION - ULTRA AGGRESSIVE v3.1"
#property version "3.10"
#property strict
#include <Trade/Trade.mqh>
CTrade Trade;
//================ INPUT PARAMETERS ==================//
input group "=== CORE SETTINGS - ULTRA AGGRESSIVE ==="
input int MagicNumber = 456789;
input double Risk_Per_Trade = 1.2;
input int Max_Trades_Per_Setup = 10; // 10 per setup
input int Max_Total_Trades = 100; // High limit
input group "=== MA SYSTEM ==="
input int MA_1 = 7;
input int MA_2 = 14;
input int MA_3 = 21;
input int MA_4 = 50;
input int MA_5 = 140;
input int MA_6 = 230;
input int MA_7 = 500;
input int MA_8 = 1000;
input int MA_9 = 1100;
input int MA_10 = 1300;
input int MA_Touch_Buffer = 100; // Wider buffer
input group "=== STOCHASTIC ==="
input int Stoch_K_Period = 5;
input int Stoch_D_Period = 3;
input int Stoch_Slowing = 3;
input double Stoch_Overbought = 70.0; // Less extreme
input double Stoch_Oversold = 30.0;
input group "=== MFIB SYSTEM ==="
input int MFIB_Lookback = 500;
input group "=== FIBONACCI ==="
input int Lookback_Bars = 200;
input bool Show_Levels = true;
input group "=== 300 RULE EXIT SYSTEM ==="
input int Initial_SL_Points = 300;
input int BreakEven_Points = 300;
input int Trailing_Distance_Points = 300;
input int TP_Points = 1500;
input int Partial_TP_Points = 900;
input double Partial_TP_Percent = 33.0;
//================ ENUMS ==================//
enum SETUP_TYPE {
SETUP_MA14_CROSS = 1,
SETUP_MA50_BOUNCE = 2,
SETUP_MA140_BOUNCE = 3,
SETUP_MA230_BOUNCE = 4,
SETUP_MA500_TOUCH = 5,
SETUP_FIB_BREAK = 6,
SETUP_FIB_RECLAIM = 7,
SETUP_FIB_REJECT = 8,
SETUP_MAGNET_WALK = 9,
SETUP_STAIRCASE_ADV = 10,
SETUP_CTRL_PULLBACK = 11,
SETUP_TF_RESET = 12,
SETUP_MFIB_LADDER = 13,
SETUP_MFIB_PRESS = 14,
SETUP_MEAN_REV = 15,
SETUP_RANGE_ENGINE = 16
};
//================ GLOBALS ==================//
int Stoch_Handle, ATR_Handle;
double Stoch_K_Current = 0;
double Stoch_K_Previous = 0;
double Current_ATR = 0;
double PriceLevels[7];
int MA_Handles[10];
double MA_Current[10];
double MA_Previous[10];
double MFIB_High, MFIB_Low;
double MFIB_Level_236, MFIB_Level_382, MFIB_Level_050;
double MFIB_Level_618, MFIB_Level_786;
bool Current_Trend_Bullish = false;
bool Current_Trend_Bearish = false;
bool Current_Trend_Ranging = false;
bool Price_Above_500 = false;
struct Position {
ulong ticket;
double entry;
double original_lot;
bool is_buy;
bool partial_tp_hit;
bool be_set;
bool trailing_active;
SETUP_TYPE setup_type;
string setup_name;
};
Position OpenPositions[];
int TodayTrades = 0;
datetime LastDay = 0;
// Tracking
int SetupCount[17];
datetime LastEntryTime[17];
//+------------------------------------------------------------------+
int OnInit()
{
Print("========================================");
Print("ULTRA AGGRESSIVE MODE v3.1");
Print("NO DAILY LIMITS | EVERY TICK ENTRY");
Print("ALL 16 SETUPS FIRING CONSTANTLY");
Print("========================================");
Trade.SetExpertMagicNumber(MagicNumber);
Trade.SetDeviationInPoints(50);
Trade.SetTypeFilling(ORDER_FILLING_FOK);
Stoch_Handle = iStochastic(_Symbol, PERIOD_CURRENT, Stoch_K_Period, Stoch_D_Period,
Stoch_Slowing, MODE_SMA, STO_LOWHIGH);
ATR_Handle = iATR(_Symbol, PERIOD_CURRENT, 14);
int periods[10] = {MA_1, MA_2, MA_3, MA_4, MA_5, MA_6, MA_7, MA_8, MA_9, MA_10};
for(int i=0; i<10; i++)
{
MA_Handles[i] = iMA(_Symbol, PERIOD_CURRENT, periods[i], 0, MODE_EMA, PRICE_CLOSE);
}
ArrayInitialize(SetupCount, 0);
ArrayInitialize(LastEntryTime, 0);
CalculateLevels();
if(Show_Levels) DrawLevels();
Print("ULTRA AGGRESSIVE: Unlimited trades, every tick, all setups!");
Print("300 Rule: SL=300, BE=300, Trail=300");
return INIT_SUCCEEDED;
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
for(int i=0; i<10; i++)
if(MA_Handles[i] != INVALID_HANDLE)
IndicatorRelease(MA_Handles[i]);
if(Stoch_Handle != INVALID_HANDLE) IndicatorRelease(Stoch_Handle);
if(ATR_Handle != INVALID_HANDLE) IndicatorRelease(ATR_Handle);
ObjectsDeleteAll(0, "Level_");
ObjectsDeleteAll(0, "Arrow_");
Print("EA Stopped - Total Trades Today: ", TodayTrades);
}
//+------------------------------------------------------------------+
void CalculateLevels()
{
double high = iHigh(_Symbol, PERIOD_CURRENT, 0);
double low = iLow(_Symbol, PERIOD_CURRENT, 0);
for(int i=1; i<=Lookback_Bars; i++)
{
double h = iHigh(_Symbol, PERIOD_CURRENT, i);
double l = iLow(_Symbol, PERIOD_CURRENT, i);
if(h > high) high = h;
if(l < low) low = l;
}
double range = high - low;
PriceLevels[0] = low;
PriceLevels[1] = low + range * 0.236;
PriceLevels[2] = low + range * 0.382;
PriceLevels[3] = low + range * 0.5;
PriceLevels[4] = low + range * 0.618;
PriceLevels[5] = low + range * 0.786;
PriceLevels[6] = high;
// MFIB
MFIB_High = high;
MFIB_Low = low;
MFIB_Level_236 = low + range * 0.236;
MFIB_Level_382 = low + range * 0.382;
MFIB_Level_050 = low + range * 0.5;
MFIB_Level_618 = low + range * 0.618;
MFIB_Level_786 = low + range * 0.786;
}
void DrawLevels()
{
ObjectsDeleteAll(0, "Level_");
color level_colors[7] = {clrRed, clrOrange, clrYellow, clrLime, clrCyan, clrBlue, clrMagenta};
for(int i=0; i<7; i++)
{
string name = "Level_" + IntegerToString(i);
ObjectCreate(0, name, OBJ_HLINE, 0, 0, PriceLevels[i]);
ObjectSetInteger(0, name, OBJPROP_COLOR, level_colors[i]);
ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_SOLID);
ObjectSetInteger(0, name, OBJPROP_WIDTH, 2);
}
}
//+------------------------------------------------------------------+
void UpdateIndicators()
{
// MAs
for(int i=0; i<10; i++)
{
double curr[1], prev[1];
if(CopyBuffer(MA_Handles[i], 0, 0, 1, curr) > 0) MA_Current[i] = curr[0];
if(CopyBuffer(MA_Handles[i], 0, 1, 1, prev) > 0) MA_Previous[i] = prev[0];
}
// Stoch
double k_curr[1], k_prev[1];
if(CopyBuffer(Stoch_Handle, MAIN_LINE, 0, 1, k_curr) > 0) Stoch_K_Current = k_curr[0];
if(CopyBuffer(Stoch_Handle, MAIN_LINE, 1, 1, k_prev) > 0) Stoch_K_Previous = k_prev[0];
// ATR
double atr[1];
if(CopyBuffer(ATR_Handle, 0, 0, 1, atr) > 0) Current_ATR = atr[0];
// Trend
bool ma7_above_ma50 = MA_Current[0] > MA_Current[3];
int bullish = 0, bearish = 0;
for(int i=0; i<5; i++)
{
if(MA_Current[i] > MA_Current[i+1]) bullish++;
if(MA_Current[i] < MA_Current[i+1]) bearish++;
}
Current_Trend_Bullish = (bullish >= 3 && ma7_above_ma50);
Current_Trend_Bearish = (bearish >= 3 && !ma7_above_ma50);
Current_Trend_Ranging = !Current_Trend_Bullish && !Current_Trend_Bearish;
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
Price_Above_500 = bid > MA_Current[6];
}
//+------------------------------------------------------------------+
int CountSetupTrades(SETUP_TYPE setup)
{
int count = 0;
for(int i=0; i<PositionsTotal(); i++)
{
if(PositionGetTicket(i) == 0) continue;
if(PositionGetString(POSITION_SYMBOL) != _Symbol) continue;
if(PositionGetInteger(POSITION_MAGIC) != MagicNumber) continue;
for(int j=0; j<ArraySize(OpenPositions); j++)
{
if(OpenPositions[j].ticket == PositionGetTicket(i))
{
if(OpenPositions[j].setup_type == setup)
count++;
break;
}
}
}
return count;
}
//+------------------------------------------------------------------+
double GetLotSize()
{
double risk = AccountInfoDouble(ACCOUNT_BALANCE) * Risk_Per_Trade / 100.0;
double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
double lot = risk / ((Initial_SL_Points * _Point / tickSize) * tickValue);
double minLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double maxLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
double step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
lot = MathMax(lot, minLot);
lot = MathMin(lot, maxLot);
lot = NormalizeDouble(lot / step, 0) * step;
return lot;
}
//+------------------------------------------------------------------+
void OpenTrade(bool buy, double price, string setup_name, SETUP_TYPE setup_type)
{
// Check setup limit
if(CountSetupTrades(setup_type) >= Max_Trades_Per_Setup) return;
// Check total limit
if(PositionsTotal() >= Max_Total_Trades) return;
// Cooldown: 1 second between same setup (prevent spam)
datetime now = TimeCurrent();
if(now - LastEntryTime[setup_type] < 1) return;
LastEntryTime[setup_type] = now;
double lot = GetLotSize();
if(lot < SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN)) return;
double sl = buy ? price - Initial_SL_Points * _Point : price + Initial_SL_Points * _Point;
double tp = buy ? price + TP_Points * _Point : price - TP_Points * _Point;
string comment = setup_name;
bool result = false;
if(buy) result = Trade.Buy(lot, _Symbol, 0, sl, tp, comment);
else result = Trade.Sell(lot, _Symbol, 0, sl, tp, comment);
if(result)
{
TodayTrades++;
SetupCount[setup_type]++;
ulong ticket = Trade.ResultOrder();
int size = ArraySize(OpenPositions);
ArrayResize(OpenPositions, size+1);
OpenPositions[size].ticket = ticket;
OpenPositions[size].entry = price;
OpenPositions[size].original_lot = lot;
OpenPositions[size].is_buy = buy;
OpenPositions[size].partial_tp_hit = false;
OpenPositions[size].be_set = false;
OpenPositions[size].trailing_active = false;
OpenPositions[size].setup_type = setup_type;
OpenPositions[size].setup_name = setup_name;
Print("", setup_name, " [", CountSetupTrades(setup_type), "/", Max_Trades_Per_Setup, "] ",
buy ? "BUY" : "SELL", " @ ", DoubleToString(price, _Digits));
}
}
//+------------------------------------------------------------------+
void ManagePositions()
{
for(int i=PositionsTotal()-1; i>=0; i--)
{
ulong ticket = PositionGetTicket(i);
if(ticket == 0) continue;
if(PositionGetString(POSITION_SYMBOL) != _Symbol) continue;
if(PositionGetInteger(POSITION_MAGIC) != MagicNumber) continue;
int idx = -1;
for(int j=0; j<ArraySize(OpenPositions); j++)
{
if(OpenPositions[j].ticket == ticket) { idx = j; break; }
}
if(idx == -1) continue;
double entry = PositionGetDouble(POSITION_PRICE_OPEN);
double current_sl = PositionGetDouble(POSITION_SL);
double current_tp = PositionGetDouble(POSITION_TP);
bool is_buy = OpenPositions[idx].is_buy;
double current = is_buy ? SymbolInfoDouble(_Symbol, SYMBOL_BID) : SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double profit_points = is_buy ? (current - entry) / _Point : (entry - current) / _Point;
// PARTIAL TP
if(!OpenPositions[idx].partial_tp_hit && profit_points >= Partial_TP_Points)
{
double current_lot = PositionGetDouble(POSITION_VOLUME);
double close_size = NormalizeDouble(OpenPositions[idx].original_lot * Partial_TP_Percent / 100.0, 2);
if(close_size > 0 && close_size <= current_lot)
{
if(Trade.PositionClosePartial(ticket, close_size))
{
OpenPositions[idx].partial_tp_hit = true;
}
}
}
// BREAKEVEN @ 300
if(!OpenPositions[idx].be_set && profit_points >= BreakEven_Points)
{
if((is_buy && current_sl < entry) || (!is_buy && current_sl > entry))
{
if(Trade.PositionModify(ticket, entry, current_tp))
{
OpenPositions[idx].be_set = true;
}
}
}
// TRAILING @ 300
if(profit_points >= BreakEven_Points + 100)
{
OpenPositions[idx].trailing_active = true;
double newSL = 0;
bool should_modify = false;
if(is_buy)
{
newSL = current - Trailing_Distance_Points * _Point;
if(newSL > current_sl + 30 * _Point) should_modify = true;
}
else
{
newSL = current + Trailing_Distance_Points * _Point;
if(newSL < current_sl - 30 * _Point) should_modify = true;
}
if(should_modify)
{
Trade.PositionModify(ticket, newSL, current_tp);
}
}
}
}
//+------------------------------------------------------------------+
void OnTick()
{
// Update every tick
UpdateIndicators();
ManagePositions();
// Recalculate levels every 100 ticks
static int tick_count = 0;
tick_count++;
if(tick_count >= 100)
{
CalculateLevels();
tick_count = 0;
}
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double current = (bid + ask) / 2;
double previous = iClose(_Symbol, PERIOD_CURRENT, 1);
double buffer = MA_Touch_Buffer * _Point;
//=================================================================
// ALL 16 SETUPS - ULTRA AGGRESSIVE - EVERY TICK
//=================================================================
// 1. MA14 CROSS
int ma14_crosses_bull = 0, ma14_crosses_bear = 0;
for(int i=0; i<10; i++)
{
if(i != 1)
{
if(MA_Current[1] > MA_Current[i]) ma14_crosses_bull++;
if(MA_Current[1] < MA_Current[i]) ma14_crosses_bear++;
}
}
if(ma14_crosses_bull >= 2)
OpenTrade(true, ask, "MA14-CROSS", SETUP_MA14_CROSS);
if(ma14_crosses_bear >= 2)
OpenTrade(false, bid, "MA14-CROSS", SETUP_MA14_CROSS);
// 2. MA50 BOUNCE
if(MathAbs(current - MA_Current[3]) <= buffer)
{
if(current >= MA_Current[3])
OpenTrade(true, ask, "MA50-BOUNCE↑", SETUP_MA50_BOUNCE);
else
OpenTrade(false, bid, "MA50-BOUNCE↓", SETUP_MA50_BOUNCE);
}
// 3. MA140 BOUNCE
if(MathAbs(current - MA_Current[4]) <= buffer)
{
if(current >= MA_Current[4])
OpenTrade(true, ask, "MA140-BOUNCE↑", SETUP_MA140_BOUNCE);
else
OpenTrade(false, bid, "MA140-BOUNCE↓", SETUP_MA140_BOUNCE);
}
// 4. MA230 BOUNCE
if(MathAbs(current - MA_Current[5]) <= buffer)
{
if(current >= MA_Current[5])
OpenTrade(true, ask, "MA230-BOUNCE↑", SETUP_MA230_BOUNCE);
else
OpenTrade(false, bid, "MA230-BOUNCE↓", SETUP_MA230_BOUNCE);
}
// 5. MA500 TOUCH
if(MathAbs(current - MA_Current[6]) <= buffer)
{
if(Current_Trend_Bullish || Price_Above_500)
OpenTrade(true, ask, "MA500-TOUCH", SETUP_MA500_TOUCH);
else
OpenTrade(false, bid, "MA500-TOUCH", SETUP_MA500_TOUCH);
}
// 6. FIB BREAKS (all levels)
for(int i=1; i<6; i++)
{
if(MathAbs(current - PriceLevels[i]) <= buffer)
{
if(previous < PriceLevels[i] && current >= PriceLevels[i])
OpenTrade(true, ask, "FIB-BREAK↑", SETUP_FIB_BREAK);
if(previous > PriceLevels[i] && current <= PriceLevels[i])
OpenTrade(false, bid, "FIB-BREAK↓", SETUP_FIB_BREAK);
}
}
// 7. FIB RECLAIM (0.382 & 0.618)
if(MathAbs(current - PriceLevels[2]) <= buffer)
{
if(previous < PriceLevels[2] && current >= PriceLevels[2])
OpenTrade(true, ask, "FIB382-RECLAIM", SETUP_FIB_RECLAIM);
}
if(MathAbs(current - PriceLevels[4]) <= buffer)
{
if(previous > PriceLevels[4] && current <= PriceLevels[4])
OpenTrade(false, bid, "FIB618-RECLAIM", SETUP_FIB_RECLAIM);
}
// 8. FIB REJECT
double prev2 = iClose(_Symbol, PERIOD_CURRENT, 2);
for(int i=2; i<5; i++)
{
if(prev2 < PriceLevels[i] && previous > PriceLevels[i] && current < PriceLevels[i])
OpenTrade(false, bid, "FIB-REJECT↓", SETUP_FIB_REJECT);
if(prev2 > PriceLevels[i] && previous < PriceLevels[i] && current > PriceLevels[i])
OpenTrade(true, ask, "FIB-REJECT↑", SETUP_FIB_REJECT);
}
// 9. MAGNET WALK
bool hugging = (MathAbs(current - MA_Current[2]) / Current_ATR < 0.7) ||
(MathAbs(current - MA_Current[3]) / Current_ATR < 0.7);
if(hugging && Stoch_K_Current > 35)
OpenTrade(true, ask, "MAGNET-WALK", SETUP_MAGNET_WALK);
if(hugging && Stoch_K_Current < 65)
OpenTrade(false, bid, "MAGNET-WALK", SETUP_MAGNET_WALK);
// 10. STAIRCASE ADVANCE
if(MA_Current[1] > MA_Previous[1] && MA_Current[1] > MA_Current[3])
OpenTrade(true, ask, "STAIRCASE-UP", SETUP_STAIRCASE_ADV);
if(MA_Current[1] < MA_Previous[1] && MA_Current[1] < MA_Current[3])
OpenTrade(false, bid, "STAIRCASE-DOWN", SETUP_STAIRCASE_ADV);
// 11. CONTROLLED PULLBACK
bool near_ma = MathAbs(current - MA_Current[2]) / Current_ATR < 1.2 ||
MathAbs(current - MA_Current[3]) / Current_ATR < 1.5;
bool stoch_reset_bull = Stoch_K_Previous > 55 && Stoch_K_Current < 50;
bool stoch_reset_bear = Stoch_K_Previous < 45 && Stoch_K_Current > 50;
if(near_ma && stoch_reset_bull)
OpenTrade(true, ask, "CTRL-PULLBACK", SETUP_CTRL_PULLBACK);
if(near_ma && stoch_reset_bear)
OpenTrade(false, bid, "CTRL-PULLBACK", SETUP_CTRL_PULLBACK);
// 12. TIMEFRAME RESET
if(Price_Above_500 && Stoch_K_Current < 35)
OpenTrade(true, ask, "TF-RESET", SETUP_TF_RESET);
if(!Price_Above_500 && Stoch_K_Current > 65)
OpenTrade(false, bid, "TF-RESET", SETUP_TF_RESET);
// 13. MFIB LADDER
if(MathAbs(current - MFIB_Level_618) <= buffer)
{
if(previous <= MFIB_Level_618 && current > MFIB_Level_618)
OpenTrade(true, ask, "MFIB-LADDER618", SETUP_MFIB_LADDER);
if(previous >= MFIB_Level_618 && current < MFIB_Level_618)
OpenTrade(false, bid, "MFIB-LADDER618", SETUP_MFIB_LADDER);
}
if(MathAbs(current - MFIB_Level_050) <= buffer)
{
if(previous <= MFIB_Level_050 && current > MFIB_Level_050)
OpenTrade(true, ask, "MFIB-LADDER50", SETUP_MFIB_LADDER);
if(previous >= MFIB_Level_050 && current < MFIB_Level_050)
OpenTrade(false, bid, "MFIB-LADDER50", SETUP_MFIB_LADDER);
}
// 14. MFIB PRESS
bool near_mfib = MathAbs(current - MFIB_Level_050) / Current_ATR < 1.2;
if(near_mfib && MA_Current[1] > MA_Current[3])
OpenTrade(true, ask, "MFIB-PRESS", SETUP_MFIB_PRESS);
if(near_mfib && MA_Current[1] < MA_Current[3])
OpenTrade(false, bid, "MFIB-PRESS", SETUP_MFIB_PRESS);
// 15. MEAN REVERSION
bool near_230 = MathAbs(current - MA_Current[5]) / Current_ATR < 1.0;
bool near_500 = MathAbs(current - MA_Current[6]) / Current_ATR < 1.2;
if((near_230 || near_500) && Stoch_K_Current < Stoch_Oversold)
OpenTrade(true, ask, "MEAN-REV", SETUP_MEAN_REV);
if((near_230 || near_500) && Stoch_K_Current > Stoch_Overbought)
OpenTrade(false, bid, "MEAN-REV", SETUP_MEAN_REV);
// 16. RANGE ENGINE
if(Current_Trend_Ranging)
{
// Buy at low fibs
if(MathAbs(current - PriceLevels[1]) < buffer && Stoch_K_Current < 35)
OpenTrade(true, ask, "RANGE-LOW", SETUP_RANGE_ENGINE);
if(MathAbs(current - PriceLevels[2]) < buffer && Stoch_K_Current < 40)
OpenTrade(true, ask, "RANGE-LOW", SETUP_RANGE_ENGINE);
// Sell at high fibs
if(MathAbs(current - PriceLevels[4]) < buffer && Stoch_K_Current > 65)
OpenTrade(false, bid, "RANGE-HIGH", SETUP_RANGE_ENGINE);
if(MathAbs(current - PriceLevels[5]) < buffer && Stoch_K_Current > 60)
OpenTrade(false, bid, "RANGE-HIGH", SETUP_RANGE_ENGINE);
}
// EXTRA AGGRESSIVE: Price at ANY MA = Entry opportunity
for(int i=3; i<=6; i++) // MA50, 140, 230, 500
{
if(MathAbs(current - MA_Current[i]) <= buffer)
{
if(MA_Current[i] > MA_Current[i+1])
OpenTrade(true, ask, "MA-CONFLUENCE", SETUP_MA500_TOUCH);
else
OpenTrade(false, bid, "MA-CONFLUENCE", SETUP_MA500_TOUCH);
}
}
}
//+------------------------------------------------------------------+