Robo Swing Trader Consistente
- Uzmanlar
- Joao Pedro Vargem Ferreira
- Sürüm: 1.0
Robô MQL5 para BTCUSD que opera cruzamento da EMA100, entra após confirmação com pivôs (fractal/zigzag), usa stop fixo 250 pontos abaixo do último fundo/topo e alvo definido. Faz no máximo 3 operações por dia (1 gain ou até 2 loss com gale), mantém o lote no dia seguinte e opera só das 08:00 às 16:00 (Brasília).apos contratar , deixe rodando por 1 semana com margem sempre acima de 20 usd. utilize a corretora abaixo para ter acesso a conta CENT >>>> https://fbs.partners?ibl=44536&ibp=5690088 <<< ideal para contas com margem inicialmente curtas.
Fique a vontade para tirar duvidas no chat.. Sou desenvolvedor e entro aqui diariamente.se eu não souber resolver , sei quem sabe.
voltando ao robo..que rendeu 61% de lucro em 2025
(operacional antigo de livros ( Elliot) )
pernada 3,onda3
(3).3
--------------------------------------------------------------------------------------
inicio do cod do ( #property strict ) pra baixo ..
#property strict
#property version "REX7.2.2_OPT_FIX_PRO"
#include <Trade/Trade.mqh>
CTrade trade;
//==================== INPUTS ====================//
input long Magic = 330033;
input double FixedInitialLot = 0.20;
input double GaleMultiplier = 2.0;
input int MaxGales = 2;
input double WeeklyDDLimit = 80;
input double DailyGainTarget = 1;
input double FiboTP = 1.161;
input double PartialPercent = 95;
input int PartialAfterMinutes = 5;
input int SlippagePoints = 30;
input bool UseTimeFilter = true;
input int StartHour = 6;
input int EndHour = 18;
input int TradeCooldownMinutes = 20;
//==================== STRUCTURAL STOP ====================//
int counterAgainst=0;
double entryCandleHigh=0;
double entryCandleLow=0;
int positionDirection=0;
//==================== SCORE ====================//
int totalWins=0;
int totalLosses=0;
int totalTrades=0;
double todayProfit=0;
bool lastGateBuy=false;
bool lastGateSell=false;
datetime lastTradeOpenTime=0;
//==================== GLOBALS ====================//
int hMA200;
int hMA75;
int hMA9;
datetime lastBar;
int galeLevel=0;
double weeklyStartEquity;
bool weeklyLock=false;
double dailyStartBalance;
bool dailyLock=false;
datetime lastDayCheck=0;
ulong partialTicketDone=0;
datetime lastPartialAttempt=0;
//==================== HELPERS ====================//
double PointValue(){ return SymbolInfoDouble(_Symbol,SYMBOL_POINT); }
int DigitsSym(){ return (int)SymbolInfoInteger(_Symbol,SYMBOL_DIGITS); }
double NormalizePrice(double p)
{
return NormalizeDouble(p,DigitsSym());
}
bool IsNewBar()
{
datetime t=iTime(_Symbol,_Period,0);
if(t!=lastBar)
{
lastBar=t;
return true;
}
return false;
}
bool IsTradingTime()
{
if(!UseTimeFilter) return true;
MqlDateTime tm;
TimeToStruct(TimeCurrent(),tm);
if(StartHour<EndHour)
return (tm.hour>=StartHour && tm.hour<EndHour);
return (tm.hour>=StartHour || tm.hour<EndHour);
}
bool HasPosition()
{
if(!PositionSelect(_Symbol)) return false;
if(PositionGetInteger(POSITION_MAGIC)!=Magic) return false;
return true;
}
//==================== MA ====================//
double GetMA(int handle,int shift)
{
double buf[];
if(CopyBuffer(handle,0,shift,1,buf)!=1)
return EMPTY_VALUE;
return buf[0];
}
//==================== LOT ====================//
double CalculateLot()
{
double lotStep=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
double minLot=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
double maxLot=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
double lot=FixedInitialLot*MathPow(GaleMultiplier,galeLevel);
lot=MathMax(minLot,MathMin(maxLot,lot));
lot=MathFloor(lot/lotStep)*lotStep;
return lot;
}
//==================== BROKER PROTECTION ====================//
bool BrokerCanTrade()
{
if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)) return false;
if(!AccountInfoInteger(ACCOUNT_TRADE_ALLOWED)) return false;
if(!AccountInfoInteger(ACCOUNT_TRADE_EXPERT)) return false;
return true;
}
//==================== WEEKLY DD ====================//
void CheckWeeklyDD()
{
double equity=AccountInfoDouble(ACCOUNT_EQUITY);
if(weeklyStartEquity<=0) return;
double dd=(weeklyStartEquity-equity)/weeklyStartEquity*100.0;
if(dd>=WeeklyDDLimit) weeklyLock=true;
}
//==================== DAILY TARGET ====================//
void CheckDailyTarget()
{
MqlDateTime now;
TimeToStruct(TimeCurrent(),now);
MqlDateTime last;
TimeToStruct(lastDayCheck,last);
if(now.day!=last.day)
{
dailyStartBalance=AccountInfoDouble(ACCOUNT_BALANCE);
dailyLock=false;
lastDayCheck=TimeCurrent();
return;
}
double profitToday=AccountInfoDouble(ACCOUNT_EQUITY)-dailyStartBalance;
if(profitToday>=DailyGainTarget)
dailyLock=true;
}
//==================== GATE STRUCTURAL ====================//
void UpdateGate()
{
double ma200=GetMA(hMA200,1);
double ma75=GetMA(hMA75,1);
double close1=iClose(_Symbol,_Period,1);
double open1=iOpen(_Symbol,_Period,1);
lastGateBuy = (close1>ma200 && close1>ma75 && open1<ma200);
lastGateSell = (close1<ma200 && close1<ma75 && open1>ma200);
}
//==================== SIGNAL ====================//
int Signal_3Wave()
{
double ma200=GetMA(hMA200,1);
double ma75=GetMA(hMA75,1);
double ma9_1=GetMA(hMA9,1);
double ma9_2=GetMA(hMA9,2);
if(ma200==EMPTY_VALUE || ma75==EMPTY_VALUE || ma9_1==EMPTY_VALUE) return 0;
double close1=iClose(_Symbol,_Period,1);
double close2=iClose(_Symbol,_Period,2);
if(close1>ma200 && close1>ma75)
if(close2<ma9_2 && close1>ma9_1 && lastGateBuy)
return 1;
if(close1<ma200 && close1<ma75)
if(close2>ma9_2 && close1<ma9_1 && lastGateSell)
return -1;
return 0;
}
//==================== STRUCTURAL STOP ====================//
void CheckStructuralStop()
{
if(!PositionSelect(_Symbol)) return;
if(PositionGetInteger(POSITION_MAGIC)!=Magic) return;
int type=(int)PositionGetInteger(POSITION_TYPE);
double entryHigh=entryCandleHigh;
double entryLow=entryCandleLow;
int countAgainst=0;
for(int i=1;i<=3;i++)
{
double c=iClose(_Symbol,_Period,i);
if(type==POSITION_TYPE_BUY)
{
if(c < entryLow) countAgainst++;
}
if(type==POSITION_TYPE_SELL)
{
if(c > entryHigh) countAgainst++;
}
}
if(countAgainst>=3)
{
trade.PositionClose(_Symbol);
}
}
//==================== PARCIAL ====================//
void ManagePartial()
{
if(!PositionSelect(_Symbol)) return;
if(PositionGetInteger(POSITION_MAGIC)!=Magic) return;
ulong ticket=PositionGetInteger(POSITION_TICKET);
double profit=PositionGetDouble(POSITION_PROFIT);
datetime openTime=(datetime)PositionGetInteger(POSITION_TIME);
if((TimeCurrent()-openTime) < PartialAfterMinutes*60)
return;
if(partialTicketDone==ticket) return;
if(profit<=0)
{
if((TimeCurrent()-lastPartialAttempt)<300)
return;
lastPartialAttempt=TimeCurrent();
return;
}
double volume=PositionGetDouble(POSITION_VOLUME);
double step=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
double minLot=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
double closeVol=volume*(PartialPercent/100.0);
closeVol=MathFloor(closeVol/step)*step;
if(closeVol<minLot || volume-closeVol<minLot) return;
trade.SetDeviationInPoints(SlippagePoints);
if(trade.PositionClosePartial(_Symbol,closeVol))
{
if(PositionSelect(_Symbol))
{
double entry=PositionGetDouble(POSITION_PRICE_OPEN);
double tp=PositionGetDouble(POSITION_TP);
trade.PositionModify(_Symbol,NormalizePrice(entry),tp);
}
partialTicketDone=ticket;
}
}
//==================== INIT ====================//
int OnInit()
{
hMA200=iMA(_Symbol,_Period,200,0,MODE_EMA,PRICE_CLOSE);
hMA75=iMA(_Symbol,_Period,75,0,MODE_EMA,PRICE_CLOSE);
hMA9=iMA(_Symbol,_Period,9,0,MODE_EMA,PRICE_CLOSE);
weeklyStartEquity=AccountInfoDouble(ACCOUNT_EQUITY);
dailyStartBalance=AccountInfoDouble(ACCOUNT_BALANCE);
lastBar=iTime(_Symbol,_Period,0);
lastDayCheck=TimeCurrent();
return INIT_SUCCEEDED;
}
//==================== ON TICK ====================//
void OnTick()
{
CheckStructuralStop();
ManagePartial();
CheckWeeklyDD();
CheckDailyTarget();
static ulong lastHistoryTicket=0;
HistorySelect(0,TimeCurrent());
int total=HistoryDealsTotal();
if(total>0)
{
ulong ticket=HistoryDealGetTicket(total-1);
if(ticket!=lastHistoryTicket)
{
double profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
if(profit>0) totalWins++;
if(profit<0) totalLosses++;
totalTrades++;
lastHistoryTicket=ticket;
lastTradeOpenTime=TimeCurrent();
galeLevel=0;
}
}
if(lastTradeOpenTime>0)
{
if((TimeCurrent()-lastTradeOpenTime) < TradeCooldownMinutes*60)
return;
}
if(weeklyLock) return;
if(dailyLock) return;
if(!IsTradingTime()) return;
if(!BrokerCanTrade()) return;
if(HasPosition()) return;
if(!IsNewBar()) return;
UpdateGate();
int sig=Signal_3Wave();
if(sig==0) return;
double lot=CalculateLot();
if(lot<=0) return;
double ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
double bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);
trade.SetExpertMagicNumber(Magic);
trade.SetDeviationInPoints(SlippagePoints);
if(sig>0)
{
double entry=ask;
double prevLow=iLow(_Symbol,_Period,1);
entryCandleLow=prevLow;
entryCandleHigh=iHigh(_Symbol,_Period,1);
double sl=NormalizePrice(prevLow);
double risk=entry-sl;
if(risk<=0) return;
double tp=NormalizePrice(entry+(risk*FiboTP));
trade.Buy(lot,_Symbol,0,sl,tp);
}
else
{
double entry=bid;
double prevHigh=iHigh(_Symbol,_Period,1);
entryCandleHigh=prevHigh;
entryCandleLow=iLow(_Symbol,_Period,1);
double sl=NormalizePrice(prevHigh);
double risk=sl-entry;
if(risk<=0) return;
double tp=NormalizePrice(entry-(risk*FiboTP));
trade.Sell(lot,_Symbol,0,sl,tp);
}
DrawScorePanel();
}
//==================== SCORE PANEL ====================//
void DrawScorePanel()
{
todayProfit = AccountInfoDouble(ACCOUNT_EQUITY) - dailyStartBalance;
double winrate=0;
if(totalTrades>0)
winrate=(double)totalWins/(double)totalTrades*100.0;
string statusEA = (weeklyLock||dailyLock ? "LOCKED":"ACTIVE");
Comment(
"\n====== REX SCORE ======",
"\nTrades: ",totalTrades,
"\nWins: ",totalWins,
"\nLosses: ",totalLosses,
"\nWinrate: ",DoubleToString(winrate,2),"%",
"\nProfit Today: ",DoubleToString(todayProfit,2),
"\n\nStatus EA: ",statusEA
);
}
daqui pra cima é um cod de um EA de DAy trade extremamente lucrativo ...
------------------------------------------------------------------------------------------------------------------------------
