//+------------------------------------------------------------------+ // FibFractalPendingEAComplete.mq5 // …
- User
//+------------------------------------------------------------------+ //| FibFractalPendingEA_Complete.mq5 | //| EA cu Fibonacci, fractali, trailing, break-even, MM, log | //+------------------------------------------------------------------+ #property copyright "ChatGPT" #property version "1.2" #property strict #include <Trade\Trade.mqh>
input int LookbackCandles = 50; input int LevelTolerancePoints = 10; input int PendingOrderMaxLifetime = 300; // secunde expirare ordin pendinte input double RiskPercent = 1.0; // % risc pe tranzacție input int VolumeMAPeriod = 14; input double VolumeThreshold = 1000.0; // prag volum (ajustabil) input bool EnableVolumeFilter = true; input bool UseActiveTimeFilter = true; input int ActiveHourStart = 9; input int ActiveHourEnd = 19; input bool EnableTrailingStop = true; input int TrailingStopPoints = 200; input int TrailingStep = 50; input bool EnableBreakEven = true; input int BreakEvenActivation = 150; input int BreakEvenBufferPoints = 10;
#define MAGIC_NUMBER 123456
CTrade trade; double FibonacciLevels[5] = {23.6, 38.2, 50.0, 61.8, 78.6}; double fibLevels[]; int fractals_handle = INVALID_HANDLE; datetime lastBarTime = 0; datetime Time[]; // ✅ Declarat ca datetime
struct TradeStat { ulong ticket; double profit; datetime openTime; datetime closeTime; ENUM_POSITION_TYPE type; };
TradeStat tradeStats[]; int tradeCount = 0; double maxDrawdown = 0; double maxBalance = 0;
int OnInit() { ArrayResize(fibLevels, ArraySize(FibonacciLevels)); fractals_handle = iFractals(_Symbol, Period()); if(fractals_handle == INVALID_HANDLE) { Print("Eroare la creare handle fractali!"); return(INIT_FAILED); } Print("EA initializat"); return(INIT_SUCCEEDED); }
void OnDeinit(const int reason) { if(fractals_handle != INVALID_HANDLE) IndicatorRelease(fractals_handle); PrintTradeStatistics(); }
void OnTick() { // ✅ Adăugăm CopyTime pentru Time[] int copied = CopyTime(_Symbol, Period(), 0, 1, Time); if(copied <= 0) return;
if(Time[0] != lastBarTime) { lastBarTime = Time[0]; if(!CalculateFibonacciLevels()) return; }
ApplyTrailingStop(); ApplyBreakEven();
if(!IsWithinActiveTime() || !IsVolumeOk()) return;
ManagePendingOrders(); // ✅ Acum funcționează
double currentPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);
for(int i=0; i<ArraySize(fibLevels); i++) { double level = fibLevels[i]; if(level < currentPrice) PlacePendingOrderWithFractalExtension(level, ORDER_TYPE_BUY_LIMIT); else if(level > currentPrice) PlacePendingOrderWithFractalExtension(level, ORDER_TYPE_SELL_LIMIT); } }
void OnTradeTransaction(const MqlTradeTransaction& trans, const MqlTradeRequest& request, const MqlTradeResult& result) { if(trans.type == TRADE_TRANSACTION_DEAL_ADD && trans.position_id != 0) { ulong ticket = trans.position_id; // ✅ Corect if(PositionSelectByTicket(ticket)) { TradeStat ts; ts.ticket = ticket; ts.profit = PositionGetDouble(POSITION_PROFIT); ts.openTime = (datetime)PositionGetInteger(POSITION_TIME); ts.closeTime = TimeCurrent(); ts.type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE); ArrayResize(tradeStats, tradeCount + 1); tradeStats[tradeCount++] = ts; double currentBalance = AccountInfoDouble(ACCOUNT_BALANCE); if(currentBalance > maxBalance) maxBalance = currentBalance; double drawdown = maxBalance - currentBalance; if(drawdown > maxDrawdown) maxDrawdown = drawdown; } } }
- Assistant
- User
da
- Assistant
- User
ofera codul complet fara greseli de compilare
Trade.mqh Object.mqh StdLibErr.mqh OrderInfo.mqh HistoryOrderInfo.mqh PositionInfo.mqh DealInfo.mqh possible loss of data due to type conversion from 'long' to 'double' !!!MasaroFibnextlevel.mq5 395 15 'ORDER_PROPERTY_EXPIRATION' - undeclared identifier !!!MasaroFibnextlevel.mq5 420 30 'OrderGetInteger' - no one of the overloads can be applied to the function call !!!MasaroFibnextlevel.mq5 420 14 could be one of 2 function(s) !!!MasaroFibnextlevel.mq5 420 14 built-in: long OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER) !!!MasaroFibnextlevel.mq5 420 14 built-in: bool OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER,long&) !!!MasaroFibnextlevel.mq5 420 14 2 errors, 1 warnings 3 2
- Assistant
- User
possible loss of data due to type conversion from 'ulong' to 'datetime' !!!MasaroFibnextlevel.mq5 292 23 possible loss of data due to type conversion from 'long' to 'double' !!!MasaroFibnextlevel.mq5 414 15 'ORDER_PROPERTY_EXPIRATION' - undeclared identifier !!!MasaroFibnextlevel.mq5 441 30 'OrderGetInteger' - no one of the overloads can be applied to the function call !!!MasaroFibnextlevel.mq5 441 14 could be one of 2 function(s) !!!MasaroFibnextlevel.mq5 441 14 built-in: long OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER) !!!MasaroFibnextlevel.mq5 441 14 built-in: bool OrderGetInteger(ENUM_ORDER_PROPERTY_INTEGER,long&) !!!MasaroFibnextlevel.mq5 441 14 2 errors, 2 warnings 3 3
- Assistant
- User
fișier complet cu toate aceste modificări implementate
- Assistant
- User
a compilat, plaseaza ordine dar nu intra in tranzactii
2025.05.23 17:28:13.308 2025.05.01 03:51:14 failed sell limit 30 XAUUSD at 3248.770 [Invalid price] 2025.05.23 17:28:13.308 2025.05.01 03:51:14 Eroare plasare ordin: 10015 - Invalid price 2025.05.23 17:28:13.308 2025.05.01 03:51:15 order canceled [#6032 sell limit 30 XAUUSD at 3254.721] 2025.05.23 17:28:13.310 2025.05.01 03:51:15 Ordin #6032 șters din cauza expirării. 2025.05.23 17:28:13.310 2025.05.01 03:51:15 order canceled [#6031 sell limit 30 XAUUSD at 3257.177] 2025.05.23 17:28:13.312 2025.05.01 03:51:15 Ordin #6031 șters din cauza expirării. 2025.05.23 17:28:13.312 2025.05.01 03:51:15 order canceled [#6030 sell limit 30 XAUUSD at 3260.214] 2025.05.23 17:28:13.314 2025.05.01 03:51:15 Ordin #6030 șters din cauza expirării. 2025.05.23 17:28:13.314 2025.05.01 03:51:15 sell limit 30 XAUUSD at 3260.214 (3250.459 / 3251.089 / 3250.459) 2025.05.23 17:28:13.316 2025.05.01 03:51:15 Ordin pendinte plasat: 3260.21400 tip 3 lot 30.00 2025.05.23 17:28:13.316 2025.05.01 03:51:15 sell limit 30 XAUUSD at 3257.177 (3250.454 / 3251.084 / 3250.454) 2025.05.23 17:28:13.318 2025.05.01 03:51:15 Ordin pendinte plasat: 3257.17700 tip 3 lot 30.00 2025.05.23 17:28:13.318 2025.05.01 03:51:15 sell limit 30 XAUUSD at 3254.721 (3250.454 / 3251.084 / 3250.454) 2025.05.23 17:28:13.319 tester forced to stop 2025.05.23 17:28:13.320 prepare for shutdown 2025.05.23 17:28:13.320 2025.05.01 03:51:15 Ordin pendinte plasat: 3254.72100 tip 3 lot 30.00 2025.05.23 17:28:13.320 2025.05.01 03:51:15 failed sell limit 30 XAUUSD at 3252.266 [Volume limit reached] 2025.05.23 17:28:13.320 2025.05.01 03:51:15 Eroare plasare ordin: 10034 - Volume limit reached 2025.05.23 17:28:13.320 2025.05.01 03:51:15 failed sell limit 30 XAUUSD at 3248.770 [Invalid price] 2025.05.23 17:28:13.320 2025.05.01 03:51:15 Eroare plasare ordin: 10015 - Invalid price 2025.05.23 17:28:13.320 test Experts\Advisors\test!!!MasaroFibnextlevel.ex5 on XAUUSD,M5 thread finished 2025.05.23 17:28:13.321 shutdown finished
- Assistant
- User
da optimizeazacodul petru a intra in tranzactii brokerul este oanda
- Assistant