فهرست منبع

Indicator version 2 file added and EA is configured with it

WajeehSaqib-MQL 1 سال پیش
والد
کامیت
d57726666b
4فایلهای تغییر یافته به همراه48 افزوده شده و 77 حذف شده
  1. BIN
      indicator/SequentialVolumeProfileWithFVG.ex5
  2. 40 64
      indicator/SequentialVolumeProfileWithFVG.mq5
  3. BIN
      valFvgMt5.ex5
  4. 8 13
      valFvgMt5.mq5

BIN
indicator/SequentialVolumeProfileWithFVG.ex5


+ 40 - 64
indicator/SequentialVolumeProfileWithFVG.mq5

@@ -31,19 +31,13 @@ input color    BullishFVGColor=clrLime;      // Bullish FVG color
 input color    BearishFVGColor=clrDeepPink;  // Bearish FVG color
 input double   MinFVGSize=0.0;         // Minimum FVG size in points (0 = any size)
 input int      MaxBarsBack=300;        // How many bars to look back for FVG
-input     string                startHour            = "23";                                     // Start Hour
-input     string                startMin             = "59";                                     // Start Minutes
-input     string                endHour              = "00";                                     // End Hour
-input     string                endMin               = "05";                                     // End Minutes
-
-datetime expiry=D'2025.05.30 12:30:27';
 
 // Structure to hold volume profile data for a day
 struct VolumeProfileData
   {
    datetime          date;          // Trading day date
-   datetime          startTime;     // Start time for calculation (23:59 previous day)
-   datetime          endTime;       // End time for calculation (23:59 current day)
+   datetime          startTime;     // Start time for calculation (23:00 previous day)
+   datetime          endTime;       // End time for calculation (23:00 current day)
    datetime          displayStart;  // When to start displaying this profile (= endTime)
    datetime          displayEnd;    // When to stop displaying this profile (= next day's endTime)
    double            val;             // Value Area Low
@@ -59,27 +53,15 @@ VolumeProfileData g_Profiles[];
 
 // Prefix for FVG objects
 string prefix;
-datetime lastCandleTime = 0;
-datetime  startTradingTime = 0, endTradingTime = 0;
-string sep  =  ":";                // A separator as a character
-ushort u_sep;                      // The code of the separator character
-string result1[];
-
-
 //+------------------------------------------------------------------+
 //| Custom indicator initialization function                         |
 //+------------------------------------------------------------------+
 int OnInit()
   {
+
 // Set up FVG object prefix
    prefix = "VProfFVG_";
 
-   if(TimeCurrent()>expiry)
-     {
-      Comment("Inactive. Contact Provider to Activate");
-      ExpertRemove();
-      return(INIT_FAILED);
-     }
 // Initialize profile storage
    ArrayResize(g_Profiles, MaxDaysBack);
    for(int i = 0; i < MaxDaysBack; i++)
@@ -132,11 +114,12 @@ void OnTimer()
    MqlDateTime mdt;
    TimeToStruct(currentTime, mdt);
 
-// Check if it's near the 23:59 boundary (update a bit before and after)
-//if((mdt.hour == 23 && mdt.min >= 58) || (mdt.hour == 0 && mdt.min <= 5))
-//  {
-//   CalculateAllVolumeProfiles();
-//  }
+// Check if it's near the 23:00 boundary (update a bit before and after)
+// if((mdt.hour == 22 && mdt.min >= 59) || (mdt.hour == 23 && mdt.min <= 5))
+   if(newDayBar())
+     {
+      CalculateAllVolumeProfiles();
+     }
   }
 
 //+------------------------------------------------------------------+
@@ -146,24 +129,7 @@ double RoundToTickSize(double value, double tickSize)
   {
    return MathRound(value / tickSize) * tickSize;
   }
-//+------------------------------------------------------------------+
-//|                                                                  |
-//+------------------------------------------------------------------+
-bool newDayBar()
-  {
-   static datetime lastbar;
-   datetime curbar = iTime(Symbol(), PERIOD_D1, 0);
-   if(lastbar != curbar)
-     {
-      lastbar = curbar;
-      Print(" ---------------------- New Day Bar :: ---------------------- ",lastbar);
-      return (true);
-     }
-   else
-     {
-      return (false);
-     }
-  }
+
 //+------------------------------------------------------------------+
 //| Custom indicator iteration function                              |
 //+------------------------------------------------------------------+
@@ -181,23 +147,16 @@ int OnCalculate(const int rates_total,
 // Check for insufficient data
    if(rates_total < 3)
       return 0;
-
-   datetime currentTime = TimeCurrent();
-   MqlDateTime mdt;
-   TimeToStruct(currentTime, mdt);
-
-// Check if it's near the 23:59 boundary (update a bit before and after)
-   if((mdt.hour == (int)startHour && mdt.min >= (int)startMin) || (mdt.hour == (int)endHour && mdt.min <= (int)endMin))
+   if(newDayBar())
      {
-      if(lastCandleTime != iTime(Symbol(),PERIOD_D1,0))
-        {
-         //if(newDayBar())
-           {
-            CalculateAllVolumeProfiles();
-            lastCandleTime = iTime(Symbol(),PERIOD_D1,0);
-           }
-        }
+      CalculateAllVolumeProfiles();
      }
+// Calculate Volume Profiles if needed
+//if(prev_calculated == 0)
+//  {
+//   CalculateAllVolumeProfiles();
+//  }
+
 // Detect Fair Value Gaps if enabled
    if(ShowFVG)
      {
@@ -368,7 +327,7 @@ void CalculateAllVolumeProfiles()
 // Update comment with the most recent profile (index 0)
    if(ShowComment && calculatedDays > 0)
      {
-      string info = "Volume Profile (TradingView "+startHour+":"+startMin+"-"+startHour+":"+startMin+" UTC+2)\n" +
+      string info = "Volume Profile (TradingView 23:00-23:00 UTC+2)\n" +
                     "Date: " + TimeToString(g_Profiles[0].date, TIME_DATE) + " (" + GetDayOfWeekName(g_Profiles[0].date) + ")\n" +
                     "Value Area: " + DoubleToString(ValueAreaPercent, 0) + "%\n" +
                     "VAL: " + DoubleToString(g_Profiles[0].val, _Digits) + "\n" +
@@ -379,7 +338,24 @@ void CalculateAllVolumeProfiles()
       Comment(info);
      }
   }
-
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+bool newDayBar()
+  {
+   static datetime lastbar;
+   datetime curbar = iTime(Symbol(), PERIOD_D1, 0);
+   if(lastbar != curbar)
+     {
+      lastbar = curbar;
+      Print(" ---------------------- New Day Bar :: ---------------------- ",lastbar);
+      return (true);
+     }
+   else
+     {
+      return (false);
+     }
+  }
 //+------------------------------------------------------------------+
 //| Calculate time boundaries for a profile                          |
 //+------------------------------------------------------------------+
@@ -420,8 +396,8 @@ void CalculateTimeBoundaries(int index)
    string dayBeforeTradingDayStr = StringFormat("%04d.%02d.%02d", beforeMdt.year, beforeMdt.mon, beforeMdt.day);
 
 // Calculate start and end times
-   g_Profiles[index].startTime = StringToTime(dayBeforeTradingDayStr + " 23:59:00");
-   g_Profiles[index].endTime = StringToTime(tradingDayStr + " 23:59:00");
+   g_Profiles[index].startTime = StringToTime(dayBeforeTradingDayStr + " 23:00:00");
+   g_Profiles[index].endTime = StringToTime(tradingDayStr + " 23:00:00");
    g_Profiles[index].displayStart = g_Profiles[index].endTime;
   }
 
@@ -436,7 +412,7 @@ void CalculateVolumeProfileForDay(int index)
 
    Print("Calculating volume profile for ", TimeToString(tradingDay, TIME_DATE),
          " (", GetDayOfWeekName(tradingDay), ")");
-   Print("Time range: ", TimeToString(startTime), " to ", TimeToString(endTime));
+   Print("Time range: ", TimeToString(startTime), " to ", TimeToString(endTime), " Index: ", index);
 
 // Copy the OHLCV data for this day - using M1 timeframe for precision
    MqlRates rates[];

BIN
valFvgMt5.ex5


+ 8 - 13
valFvgMt5.mq5

@@ -5,7 +5,7 @@
 //+------------------------------------------------------------------+
 #property copyright "Copyright 2025, MQL Development"
 #property link      "https://www.mqldevelopment.com/"
-#property version   "1.1"
+#property version   "1.2"
 #include <Trade\Trade.mqh>
 CTrade  trade;
 #resource "\\Indicators\\SequentialVolumeProfileWithFVG.ex5"
@@ -92,11 +92,6 @@ input        color                   BearishFVGColor            = clrDeepPink;
 input        double                  MinFVGSize                 = 0.0;              // Minimum FVG size in points (0 = any size)
 input        int                     MaxBarsBack                = 300;              // How many bars to look back for FVG
 
-input        string                  startHour                  = "23";             // Start Hour
-input        string                  startMin                   = "59";             // Start Minutes
-input        string                  endHour                    = "00";             // End Hour
-input        string                  endMin                     = "05";             // End Minutes
-
 
 
 // Global Variables
@@ -105,12 +100,16 @@ datetime  startTradingTime = 0, endTradingTime = 0;
 string sep  =  ":";                // A separator as a character
 ushort u_sep;                      // The code of the separator character
 string result1[];
+
 //+------------------------------------------------------------------+
 //|                                                                  |
 //+------------------------------------------------------------------+
 int OnInit()
   {
 //---
+
+
+     
    trade.SetExpertMagicNumber(magic_no);
    trade.SetDeviationInPoints(10);
    trade.SetTypeFilling(ORDER_FILLING_IOC);
@@ -138,11 +137,7 @@ int OnInit()
                                 BullishFVGColor,
                                 BearishFVGColor,
                                 MinFVGSize,
-                                MaxBarsBack,
-                                startHour,
-                                startMin,
-                                endHour,
-                                endMin);
+                                MaxBarsBack);
 
 
 //---
@@ -528,7 +523,7 @@ string check_bearish_bullish()
 string fvg_gap()
   {
 //Print("Imbalance: ");
-//  if(check_bearish_bullish() == previousBullish)
+ //  if(check_bearish_bullish() == previousBullish)
      {
       if(iLow(Symbol(), PERIOD_CURRENT, 1) > iHigh(Symbol(), PERIOD_CURRENT, 3))
         {
@@ -553,7 +548,7 @@ string fvg_gap()
            }
         }
      }
-// if(check_bearish_bullish() == previousBearish)
+  // if(check_bearish_bullish() == previousBearish)
      {
       if(iLow(Symbol(), PERIOD_CURRENT, 3) > iHigh(Symbol(), PERIOD_CURRENT, 1))
         {