Drop any file on PC 1 — instantly view and download it on PC 2. Built for MetaTrader files (.mq5, .ex5, .set), zip archives, documents, images, and cross-computer workflows.
| File Name | Size | Uploaded Date | Actions |
|---|---|---|---|
| Loading files from Cloudflare... | |||
Real dollar drops and progressive lot sizing with dual take-profit regimes.
| Tier (Leg) | Lot Size | Drop Distance | Cumulative Vol | Take Profit Regime | Target Offset |
|---|---|---|---|---|---|
| Leg 1 | 0.01 | $2.00 | 0.01 | TP1 Regime | +$3.00 above/below VWAP |
| Leg 2 | 0.01 | $2.00 | 0.02 | TP1 Regime | +$3.00 above/below VWAP |
| Leg 3 | 0.01 | $2.50 | 0.03 | TP1 Regime | +$3.00 above/below VWAP |
| Leg 4 | 0.02 | $2.50 | 0.05 | TP1 Regime | +$3.00 above/below VWAP |
| Leg 5 | 0.02 | $3.00 | 0.07 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 6 | 0.03 | $3.00 | 0.10 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 7 | 0.03 | $3.50 | 0.13 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 8 | 0.04 | $3.50 | 0.17 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 9 | 0.05 | $4.00 | 0.22 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 10 | 0.06 | $4.00 | 0.28 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 11 | 0.07 | $4.50 | 0.35 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 12 | 0.08 | $4.50 | 0.43 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 13 | 0.10 | $5.00 | 0.53 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 14 | 0.12 | $5.00 | 0.65 | TP2 Defensive | +$1.50 above/below VWAP |
| Leg 15 | 0.15 | $5.50 | 0.80 | TP2 Defensive | +$1.50 above/below VWAP |
Ready to compile in MetaEditor 5 without external dependencies.
//+------------------------------------------------------------------+
//| V4_Micro_10K.mq5 |
//| Calibrated V4 Algorithmic Grid Engine |
//| Production Ready for 10,000 USD Demo & |
//| 10,000 USC Live Cent (Vantage XAUUSD) |
//+------------------------------------------------------------------+
#property copyright "Pro Algo"
#property link "https://projectzeta.online"
#property version "1.10"
#property description "V4 Hedging Grid with Dynamic VWAP, USD Pricing & Daily Target Lock"
#include <Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\AccountInfo.mqh>
CTrade trade;
CPositionInfo posInfo;
CAccountInfo accInfo;
//--- Input Parameters
input group "=== Risk & Capital Protection ==="
input ulong InpMagicNumber = 777010; // Magic Number
input bool InpDailyTargetLock = true; // Enable Daily Target Lock (true = stops after target)
input double InpDailyTargetValue = 200.0; // Target Value ($200 USD on Demo / 200 USC on Cent)
input bool InpAutoCloseOnDailyTarget = true; // Auto-Close Open Trades when Bagged + Floating >= Target
input double InpEquityLossPercent = 20.0; // Hard Equity Stop-Loss (% of Balance)
input int InpMaxLegsCap = 15; // Absolute Max Legs Cap per Basket
input group "=== Friday & Weekend Time Gate ==="
input bool InpFridayFlatten = true; // Auto-Flatten Open Baskets on Friday Evening
input int InpFridayHour = 20; // Friday Server Hour to Flatten (20:00)
input int InpMondayStartHour = 1; // Monday Server Hour to Start Trading (01:00)
input group "=== Trend & Filter Settings ==="
input ENUM_TIMEFRAMES InpEmaTF = PERIOD_H1; // EMA Trend Timeframe
input int InpEmaPeriod = 200; // EMA Trend Period
input double InpEmaBufferUSD = 0.50; // EMA Buffer in Dollars (prevents whipsaws)
input int InpMaxSpreadPoints = 50; // Max Spread Allowed (points) for ANY order
input group "=== Take-Profit (Real USD Price Units) ==="
input int InpMaxLegsForTP1 = 4; // Max Legs for TP1 Regime
input double InpTP1_USD = 3.00; // TP1 Target ($3.00 above/below Break-Even)
input double InpTP2_USD = 1.50; // TP2 Defensive Target ($1.50 above/below Break-Even)
input group "=== Grid Matrix (Real USD Distances & Lots) ==="
input double InpLot1 = 0.01; input double InpDistUSD1 = 2.00; // $2.00 drop
input double InpLot2 = 0.01; input double InpDistUSD2 = 2.00; // $2.00 drop
input double InpLot3 = 0.01; input double InpDistUSD3 = 2.50; // $2.50 drop
input double InpLot4 = 0.02; input double InpDistUSD4 = 2.50; // $2.50 drop
input double InpLot5 = 0.02; input double InpDistUSD5 = 3.00; // $3.00 drop
input double InpLot6 = 0.03; input double InpDistUSD6 = 3.00; // $3.00 drop
input double InpLot7 = 0.03; input double InpDistUSD7 = 3.50; // $3.50 drop
input double InpLot8 = 0.04; input double InpDistUSD8 = 3.50; // $3.50 drop
input double InpLot9 = 0.05; input double InpDistUSD9 = 4.00; // $4.00 drop
input double InpLot10 = 0.06; input double InpDistUSD10 = 4.00; // $4.00 drop
input double InpLot11 = 0.07; input double InpDistUSD11 = 4.50; // $4.50 drop
input double InpLot12 = 0.08; input double InpDistUSD12 = 4.50; // $4.50 drop
input double InpLot13 = 0.10; input double InpDistUSD13 = 5.00; // $5.00 drop
input double InpLot14 = 0.12; input double InpDistUSD14 = 5.00; // $5.00 drop
input double InpLot15 = 0.15; input double InpDistUSD15 = 5.50; // $5.50 drop
//--- Internal State
int emaHandle;
datetime lastTradeDay;
double dayStartingBalance;
bool dailyTargetHitToday = false;
double gridLots[15];
double gridDistsUSD[15];
int OnInit()
{
trade.SetExpertMagicNumber(InpMagicNumber);
trade.SetTypeFilling(ORDER_FILLING_IOC);
gridLots[0] = InpLot1; gridDistsUSD[0] = InpDistUSD1;
gridLots[1] = InpLot2; gridDistsUSD[1] = InpDistUSD2;
gridLots[2] = InpLot3; gridDistsUSD[2] = InpDistUSD3;
gridLots[3] = InpLot4; gridDistsUSD[3] = InpDistUSD4;
gridLots[4] = InpLot5; gridDistsUSD[4] = InpDistUSD5;
gridLots[5] = InpLot6; gridDistsUSD[6] = InpDistUSD6;
gridLots[6] = InpLot7; gridDistsUSD[7] = InpDistUSD7;
gridLots[7] = InpLot8; gridDistsUSD[8] = InpDistUSD8;
gridLots[8] = InpLot9; gridDistsUSD[9] = InpDistUSD9;
gridLots[9] = InpLot10; gridDistsUSD[9] = InpDistUSD10;
gridLots[10] = InpLot11; gridDistsUSD[10] = InpDistUSD11;
gridLots[11] = InpLot12; gridDistsUSD[11] = InpDistUSD12;
gridLots[12] = InpLot13; gridDistsUSD[12] = InpDistUSD13;
gridLots[13] = InpLot14; gridDistsUSD[13] = InpDistUSD14;
gridLots[14] = InpLot15; gridDistsUSD[14] = InpDistUSD15;
emaHandle = iMA(_Symbol, InpEmaTF, InpEmaPeriod, 0, MODE_EMA, PRICE_CLOSE);
if(emaHandle == INVALID_HANDLE)
{
Print("Failed to create EMA indicator handle!");
return(INIT_FAILED);
}
lastTradeDay = 0;
dayStartingBalance = accInfo.Balance();
dailyTargetHitToday = false;
Print("V4 Micro-10K Initialized Successfully on ", _Symbol);
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
if(emaHandle != INVALID_HANDLE)
IndicatorRelease(emaHandle);
Comment("");
}
double GetClosedProfitToday()
{
MqlDateTime dt;
TimeCurrent(dt);
dt.hour = 0; dt.min = 0; dt.sec = 0;
datetime startOfDay = StructToTime(dt);
HistorySelect(startOfDay, TimeCurrent());
int totalDeals = HistoryDealsTotal();
double profitToday = 0.0;
for(int i = 0; i < totalDeals; i++)
{
ulong dealTicket = HistoryDealGetTicket(i);
if(dealTicket > 0)
{
long dealMagic = HistoryDealGetInteger(dealTicket, DEAL_MAGIC);
if(dealMagic == (long)InpMagicNumber)
{
profitToday += HistoryDealGetDouble(dealTicket, DEAL_PROFIT);
profitToday += HistoryDealGetDouble(dealTicket, DEAL_SWAP);
profitToday += HistoryDealGetDouble(dealTicket, DEAL_COMMISSION);
}
}
}
return profitToday;
}
double GetFloatingProfit()
{
double floating = 0.0;
for(int i = 0; i < PositionsTotal(); i++)
{
if(posInfo.SelectByIndex(i))
{
if(posInfo.Magic() == InpMagicNumber && posInfo.Symbol() == _Symbol)
{
floating += posInfo.Profit() + posInfo.Swap();
}
}
}
return floating;
}
void CloseAllPositions(int typeFilter = -1)
{
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
if(posInfo.SelectByIndex(i))
{
if(posInfo.Magic() == InpMagicNumber && posInfo.Symbol() == _Symbol)
{
if(typeFilter == -1 || (int)posInfo.PositionType() == typeFilter)
{
trade.PositionClose(posInfo.Ticket());
}
}
}
}
}
bool CheckHardEquityStop()
{
double currentBalance = accInfo.Balance();
double currentEquity = accInfo.Equity();
if(currentBalance <= 0) return false;
double drawdownPct = ((currentBalance - currentEquity) / currentBalance) * 100.0;
if(drawdownPct >= InpEquityLossPercent)
{
PrintFormat("CIRCUIT BREAKER TRIGGERED! Drawdown: %.2f%% (>= %.2f%%). Closing all positions!",
drawdownPct, InpEquityLossPercent);
CloseAllPositions();
return true;
}
return false;
}
bool IsTradingAllowedTime()
{
MqlDateTime dt;
TimeCurrent(dt);
if(dt.day_of_week == 5 && dt.hour >= InpFridayHour)
{
if(InpFridayFlatten && PositionsTotal() > 0)
{
Print("Friday Night Flatten: Closing open baskets before weekend gap!");
CloseAllPositions();
}
return false;
}
if(dt.day_of_week == 0 || (dt.day_of_week == 1 && dt.hour < InpMondayStartHour))
{
return false;
}
return true;
}
void OnTick()
{
if(CheckHardEquityStop()) return;
bool allowNewTrades = IsTradingAllowedTime();
MqlDateTime dt;
TimeCurrent(dt);
datetime todayMidnight = StringToTime(TimeToString(TimeCurrent(), TIME_DATE) + " 00:00:00");
if(todayMidnight != lastTradeDay)
{
lastTradeDay = todayMidnight;
dayStartingBalance = accInfo.Balance();
dailyTargetHitToday = false;
}
double closedProfitToday = GetClosedProfitToday();
double floatingProfit = GetFloatingProfit();
double totalProfitToday = closedProfitToday + floatingProfit;
if(InpDailyTargetLock && !dailyTargetHitToday)
{
if(InpAutoCloseOnDailyTarget && totalProfitToday >= InpDailyTargetValue && PositionsTotal() > 0)
{
PrintFormat("DAILY TARGET REACHED! (Closed: %.2f + Floating: %.2f = Total: %.2f >= Target: %.2f). Flattening all positions!",
closedProfitToday, floatingProfit, totalProfitToday, InpDailyTargetValue);
CloseAllPositions();
dailyTargetHitToday = true;
return;
}
else if(closedProfitToday >= InpDailyTargetValue)
{
dailyTargetHitToday = true;
}
}
int buyLegs = 0, sellLegs = 0;
double buyVol = 0.0, sellVol = 0.0;
double buyWeightedPrice = 0.0, sellWeightedPrice = 0.0;
double lowestBuyPrice = 999999.0, highestSellPrice = 0.0;
for(int i = 0; i < PositionsTotal(); i++)
{
if(posInfo.SelectByIndex(i))
{
if(posInfo.Magic() == InpMagicNumber && posInfo.Symbol() == _Symbol)
{
double pVol = posInfo.Volume();
double pPrice = posInfo.PriceOpen();
if(posInfo.PositionType() == POSITION_TYPE_BUY)
{
buyLegs++;
buyVol += pVol;
buyWeightedPrice += (pPrice * pVol);
if(pPrice < lowestBuyPrice) lowestBuyPrice = pPrice;
}
else if(posInfo.PositionType() == POSITION_TYPE_SELL)
{
sellLegs++;
sellVol += pVol;
sellWeightedPrice += (pPrice * pVol);
if(pPrice > highestSellPrice) highestSellPrice = pPrice;
}
}
}
}
double buyVWAP = (buyVol > 0) ? (buyWeightedPrice / buyVol) : 0.0;
double sellVWAP = (sellVol > 0) ? (sellWeightedPrice / sellVol) : 0.0;
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
int digits = (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);
long currentSpread = SymbolInfoInteger(_Symbol, SYMBOL_SPREAD);
if(buyLegs > 0 && buyVWAP > 0)
{
double buyTargetOffset = (buyLegs <= InpMaxLegsForTP1) ? InpTP1_USD : InpTP2_USD;
double buyTPPrice = NormalizeDouble(buyVWAP + buyTargetOffset, digits);
for(int i = 0; i < PositionsTotal(); i++)
{
if(posInfo.SelectByIndex(i))
{
if(posInfo.Magic() == InpMagicNumber && posInfo.Symbol() == _Symbol && posInfo.PositionType() == POSITION_TYPE_BUY)
{
if(MathAbs(posInfo.TakeProfit() - buyTPPrice) > (point * 5))
{
trade.PositionModify(posInfo.Ticket(), posInfo.StopLoss(), buyTPPrice);
}
}
}
}
if(bid >= buyTPPrice)
{
PrintFormat("BUY Basket Hit TP ($%.2f above VWAP). Closing Basket!", buyTargetOffset);
CloseAllPositions(POSITION_TYPE_BUY);
buyLegs = 0;
}
}
if(sellLegs > 0 && sellVWAP > 0)
{
double sellTargetOffset = (sellLegs <= InpMaxLegsForTP1) ? InpTP1_USD : InpTP2_USD;
double sellTPPrice = NormalizeDouble(sellVWAP - sellTargetOffset, digits);
for(int i = 0; i < PositionsTotal(); i++)
{
if(posInfo.SelectByIndex(i))
{
if(posInfo.Magic() == InpMagicNumber && posInfo.Symbol() == _Symbol && posInfo.PositionType() == POSITION_TYPE_SELL)
{
if(MathAbs(posInfo.TakeProfit() - sellTPPrice) > (point * 5))
{
trade.PositionModify(posInfo.Ticket(), posInfo.StopLoss(), sellTPPrice);
}
}
}
}
if(ask <= sellTPPrice)
{
PrintFormat("SELL Basket Hit TP ($%.2f below VWAP). Closing Basket!", sellTargetOffset);
CloseAllPositions(POSITION_TYPE_SELL);
sellLegs = 0;
}
}
if(allowNewTrades && (!InpDailyTargetLock || !dailyTargetHitToday) && currentSpread <= InpMaxSpreadPoints)
{
if(buyLegs > 0 && buyLegs < InpMaxLegsCap)
{
int nextTier = MathMin(buyLegs, 14);
double reqDistUSD = gridDistsUSD[nextTier];
if(lowestBuyPrice - ask >= reqDistUSD)
{
double nextLot = gridLots[nextTier];
trade.Buy(nextLot, _Symbol, ask, 0, 0, "V4 Buy Leg " + IntegerToString(buyLegs + 1));
}
}
if(sellLegs > 0 && sellLegs < InpMaxLegsCap)
{
int nextTier = MathMin(sellLegs, 14);
double reqDistUSD = gridDistsUSD[nextTier];
if(bid - highestSellPrice >= reqDistUSD)
{
double nextLot = gridLots[nextTier];
trade.Sell(nextLot, _Symbol, bid, 0, 0, "V4 Sell Leg " + IntegerToString(sellLegs + 1));
}
}
}
if(allowNewTrades && (!InpDailyTargetLock || !dailyTargetHitToday))
{
if(currentSpread <= InpMaxSpreadPoints)
{
double emaValues[1];
if(CopyBuffer(emaHandle, 0, 0, 1, emaValues) > 0)
{
double emaTrend = emaValues[0];
double currentMid = (ask + bid) / 2.0;
if(currentMid > (emaTrend + InpEmaBufferUSD) && buyLegs == 0)
{
trade.Buy(InpLot1, _Symbol, ask, 0, 0, "V4 Initial Buy");
}
else if(currentMid < (emaTrend - InpEmaBufferUSD) && sellLegs == 0)
{
trade.Sell(InpLot1, _Symbol, bid, 0, 0, "V4 Initial Sell");
}
}
}
}
string statusText = "TRADING ACTIVE";
if(!allowNewTrades)
{
statusText = "PAUSED (WEEKEND TIME GATE)";
}
else if(InpDailyTargetLock && dailyTargetHitToday)
{
statusText = "DAILY TARGET HIT (LOCKED UNTIL MIDNIGHT) ✓";
}
string hud = "";
hud += "========================================\n";
hud += " V4 MICRO-10K ALGO ENGINE \n";
hud += "========================================\n";
hud += StringFormat("Account Balance: %.2f\n", accInfo.Balance());
hud += StringFormat("Account Equity: %.2f\n", accInfo.Equity());
hud += StringFormat("Closed Profit: %.2f\n", closedProfitToday);
hud += StringFormat("Floating PnL: %.2f\n", floatingProfit);
hud += StringFormat("Total Net Today: %.2f / %.2f (%s)\n",
totalProfitToday, InpDailyTargetValue,
dailyTargetHitToday ? "LOCKED ✓" : "PROGRESS");
hud += "----------------------------------------\n";
hud += StringFormat("BUY Basket: %d Legs (Vol: %.2f) | VWAP: %.*f\n", buyLegs, buyVol, digits, buyVWAP);
hud += StringFormat("SELL Basket: %d Legs (Vol: %.2f) | VWAP: %.*f\n", sellLegs, sellVol, digits, sellVWAP);
hud += StringFormat("Spread: %d pts | Status: %s\n", currentSpread, statusText);
hud += "========================================";
Comment(hud);
}
//+------------------------------------------------------------------+