138 righe
4,6 KiB
MQL5
138 righe
4,6 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| TLBSimon Gold Scalper 0/0 + Risk Guard - Auto Setup |
|
|
//| Version: 1.0 - Forge MQL5 Starter |
|
|
//| Stack: XAUUSD M15 London Breakout PF1.48 |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "TLBSimon - NBS Certified, 1800+ days live"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//--- INPUTS - editable from Set screen (ako chce Tradetron klient)
|
|
input group "=== EMA Scalping Core ==="
|
|
input int FastEMA = 21;
|
|
input int SlowEMA = 55;
|
|
input ENUM_TIMEFRAMES Timeframe = PERIOD_M15;
|
|
|
|
input group "=== Risk Guard - TLBSimon ==="
|
|
input double LotSize = 0.01;
|
|
input int StopLossPoints = 300; // 30 pips na Gold
|
|
input int TakeProfitPoints = 600;
|
|
input double DailyMaxDD_Percent = 3.0; // Daily 3% blocker
|
|
input double TotalMaxDD_Percent = 8.0; // Total 8% blocker
|
|
|
|
input group "=== Session Filter ==="
|
|
input int LondonStartHour = 8;
|
|
input int LondonEndHour = 11;
|
|
|
|
double daily_start_balance = 0;
|
|
datetime daily_reset_time = 0;
|
|
|
|
//+------------------------------------------------------------------+
|
|
int OnInit()
|
|
{
|
|
Print("TLBSimon Bot - Auto Setup Start");
|
|
|
|
// Auto setup - kontrola symbolu
|
|
if(StringFind(_Symbol, "GOLD") < 0 && StringFind(_Symbol, "XAU") < 0)
|
|
{
|
|
Print("WARNING: Odporucany symbol XAUUSD, teraz mas: ", _Symbol);
|
|
}
|
|
|
|
// Risk Guard - uloz start balance
|
|
daily_start_balance = AccountInfoDouble(ACCOUNT_BALANCE);
|
|
daily_reset_time = TimeCurrent();
|
|
|
|
Print("Setup OK: FastEMA=", FastEMA, " SlowEMA=", SlowEMA, " Lot=", LotSize);
|
|
Print("Risk Guard: Daily ", DailyMaxDD_Percent, "% Total ", TotalMaxDD_Percent, "%");
|
|
Print("Forge: forge.mql5.com/TLBSimon - Ready to trade");
|
|
|
|
return(INIT_SUCCEEDED);
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
void OnDeinit(const int reason)
|
|
{
|
|
Print("TLBSimon Bot - Vypnuty. Dovod: ", reason);
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
bool RiskGuard_Check()
|
|
{
|
|
double balance = AccountInfoDouble(ACCOUNT_BALANCE);
|
|
double equity = AccountInfoDouble(ACCOUNT_EQUITY);
|
|
double dd = (daily_start_balance - equity) / daily_start_balance * 100.0;
|
|
|
|
// Daily reset o polnoci
|
|
if(TimeCurrent() - daily_reset_time > 86400)
|
|
{
|
|
daily_start_balance = balance;
|
|
daily_reset_time = TimeCurrent();
|
|
Print("Daily reset - novy start balance: ", daily_start_balance);
|
|
}
|
|
|
|
if(dd >= DailyMaxDD_Percent)
|
|
{
|
|
Print("RISK GUARD BLOCK: Daily DD ", dd, "% >= ", DailyMaxDD_Percent, "% - STOP TRADING TODAY");
|
|
return false;
|
|
}
|
|
|
|
// Total DD check
|
|
double total_dd = (AccountInfoDouble(ACCOUNT_BALANCE) - equity) / AccountInfoDouble(ACCOUNT_BALANCE) * 100.0;
|
|
if(total_dd >= TotalMaxDD_Percent)
|
|
{
|
|
Print("RISK GUARD BLOCK: Total DD ", total_dd, "% - STOP");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
bool LondonSession()
|
|
{
|
|
MqlDateTime dt;
|
|
TimeToStruct(TimeCurrent(), dt);
|
|
return (dt.hour >= LondonStartHour && dt.hour <= LondonEndHour);
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
void OnTick()
|
|
{
|
|
// 1. Risk Guard prvy
|
|
if(!RiskGuard_Check()) return;
|
|
|
|
// 2. Session filter
|
|
if(!LondonSession()) return;
|
|
|
|
// 3. Iba 1 trade naraz - Gold scalper 0/0
|
|
if(PositionsTotal() > 0) return;
|
|
|
|
// 4. EMA logika - Fast EMA crossover Slow EMA
|
|
double ema_fast[], ema_slow[];
|
|
CopyBuffer(iMA(_Symbol, Timeframe, FastEMA, 0, MODE_EMA, PRICE_CLOSE), 0, 0, 3, ema_fast);
|
|
CopyBuffer(iMA(_Symbol, Timeframe, SlowEMA, 0, MODE_EMA, PRICE_CLOSE), 0, 0, 3, ema_slow);
|
|
ArraySetAsSeries(ema_fast, true);
|
|
ArraySetAsSeries(ema_slow, true);
|
|
|
|
bool buy_signal = ema_fast[1] > ema_slow[1] && ema_fast[2] <= ema_slow[2];
|
|
bool sell_signal = ema_fast[1] < ema_slow[1] && ema_fast[2] >= ema_slow[2];
|
|
|
|
if(buy_signal)
|
|
{
|
|
// BUY
|
|
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
|
double sl = ask - StopLossPoints * _Point;
|
|
double tp = ask + TakeProfitPoints * _Point;
|
|
// trade request...
|
|
Print("BUY Signal EMA crossover ", FastEMA, "/", SlowEMA, " Ask=", ask);
|
|
}
|
|
|
|
if(sell_signal)
|
|
{
|
|
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
|
double sl = bid + StopLossPoints * _Point;
|
|
double tp = bid - TakeProfitPoints * _Point;
|
|
Print("SELL Signal EMA crossover ", FastEMA, "/", SlowEMA, " Bid=", bid);
|
|
}
|
|
}
|
|
//+------------------------------------------------------------------+
|