Explorar el Código

Indicator version 2 file added and EA is configured with it

WajeehSaqib-MQL hace 8 meses
padre
commit
d57726666b

BIN
indicator/SequentialVolumeProfileWithFVG.ex5


+ 40 - 64
indicator/SequentialVolumeProfileWithFVG.mq5

@@ -31,19 +31,13 @@ input color    BullishFVGColor=clrLime;      // Bullish FVG color
31 31
 input color    BearishFVGColor=clrDeepPink;  // Bearish FVG color
32 32
 input double   MinFVGSize=0.0;         // Minimum FVG size in points (0 = any size)
33 33
 input int      MaxBarsBack=300;        // How many bars to look back for FVG
34
-input     string                startHour            = "23";                                     // Start Hour
35
-input     string                startMin             = "59";                                     // Start Minutes
36
-input     string                endHour              = "00";                                     // End Hour
37
-input     string                endMin               = "05";                                     // End Minutes
38
-
39
-datetime expiry=D'2025.05.30 12:30:27';
40 34
 
41 35
 // Structure to hold volume profile data for a day
42 36
 struct VolumeProfileData
43 37
   {
44 38
    datetime          date;          // Trading day date
45
-   datetime          startTime;     // Start time for calculation (23:59 previous day)
46
-   datetime          endTime;       // End time for calculation (23:59 current day)
39
+   datetime          startTime;     // Start time for calculation (23:00 previous day)
40
+   datetime          endTime;       // End time for calculation (23:00 current day)
47 41
    datetime          displayStart;  // When to start displaying this profile (= endTime)
48 42
    datetime          displayEnd;    // When to stop displaying this profile (= next day's endTime)
49 43
    double            val;             // Value Area Low
@@ -59,27 +53,15 @@ VolumeProfileData g_Profiles[];
59 53
 
60 54
 // Prefix for FVG objects
61 55
 string prefix;
62
-datetime lastCandleTime = 0;
63
-datetime  startTradingTime = 0, endTradingTime = 0;
64
-string sep  =  ":";                // A separator as a character
65
-ushort u_sep;                      // The code of the separator character
66
-string result1[];
67
-
68
-
69 56
 //+------------------------------------------------------------------+
70 57
 //| Custom indicator initialization function                         |
71 58
 //+------------------------------------------------------------------+
72 59
 int OnInit()
73 60
   {
61
+
74 62
 // Set up FVG object prefix
75 63
    prefix = "VProfFVG_";
76 64
 
77
-   if(TimeCurrent()>expiry)
78
-     {
79
-      Comment("Inactive. Contact Provider to Activate");
80
-      ExpertRemove();
81
-      return(INIT_FAILED);
82
-     }
83 65
 // Initialize profile storage
84 66
    ArrayResize(g_Profiles, MaxDaysBack);
85 67
    for(int i = 0; i < MaxDaysBack; i++)
@@ -132,11 +114,12 @@ void OnTimer()
132 114
    MqlDateTime mdt;
133 115
    TimeToStruct(currentTime, mdt);
134 116
 
135
-// Check if it's near the 23:59 boundary (update a bit before and after)
136
-//if((mdt.hour == 23 && mdt.min >= 58) || (mdt.hour == 0 && mdt.min <= 5))
137
-//  {
138
-//   CalculateAllVolumeProfiles();
139
-//  }
117
+// Check if it's near the 23:00 boundary (update a bit before and after)
118
+// if((mdt.hour == 22 && mdt.min >= 59) || (mdt.hour == 23 && mdt.min <= 5))
119
+   if(newDayBar())
120
+     {
121
+      CalculateAllVolumeProfiles();
122
+     }
140 123
   }
141 124
 
142 125
 //+------------------------------------------------------------------+
@@ -146,24 +129,7 @@ double RoundToTickSize(double value, double tickSize)
146 129
   {
147 130
    return MathRound(value / tickSize) * tickSize;
148 131
   }
149
-//+------------------------------------------------------------------+
150
-//|                                                                  |
151
-//+------------------------------------------------------------------+
152
-bool newDayBar()
153
-  {
154
-   static datetime lastbar;
155
-   datetime curbar = iTime(Symbol(), PERIOD_D1, 0);
156
-   if(lastbar != curbar)
157
-     {
158
-      lastbar = curbar;
159
-      Print(" ---------------------- New Day Bar :: ---------------------- ",lastbar);
160
-      return (true);
161
-     }
162
-   else
163
-     {
164
-      return (false);
165
-     }
166
-  }
132
+
167 133
 //+------------------------------------------------------------------+
168 134
 //| Custom indicator iteration function                              |
169 135
 //+------------------------------------------------------------------+
@@ -181,23 +147,16 @@ int OnCalculate(const int rates_total,
181 147
 // Check for insufficient data
182 148
    if(rates_total < 3)
183 149
       return 0;
184
-
185
-   datetime currentTime = TimeCurrent();
186
-   MqlDateTime mdt;
187
-   TimeToStruct(currentTime, mdt);
188
-
189
-// Check if it's near the 23:59 boundary (update a bit before and after)
190
-   if((mdt.hour == (int)startHour && mdt.min >= (int)startMin) || (mdt.hour == (int)endHour && mdt.min <= (int)endMin))
150
+   if(newDayBar())
191 151
      {
192
-      if(lastCandleTime != iTime(Symbol(),PERIOD_D1,0))
193
-        {
194
-         //if(newDayBar())
195
-           {
196
-            CalculateAllVolumeProfiles();
197
-            lastCandleTime = iTime(Symbol(),PERIOD_D1,0);
198
-           }
199
-        }
152
+      CalculateAllVolumeProfiles();
200 153
      }
154
+// Calculate Volume Profiles if needed
155
+//if(prev_calculated == 0)
156
+//  {
157
+//   CalculateAllVolumeProfiles();
158
+//  }
159
+
201 160
 // Detect Fair Value Gaps if enabled
202 161
    if(ShowFVG)
203 162
      {
@@ -368,7 +327,7 @@ void CalculateAllVolumeProfiles()
368 327
 // Update comment with the most recent profile (index 0)
369 328
    if(ShowComment && calculatedDays > 0)
370 329
      {
371
-      string info = "Volume Profile (TradingView "+startHour+":"+startMin+"-"+startHour+":"+startMin+" UTC+2)\n" +
330
+      string info = "Volume Profile (TradingView 23:00-23:00 UTC+2)\n" +
372 331
                     "Date: " + TimeToString(g_Profiles[0].date, TIME_DATE) + " (" + GetDayOfWeekName(g_Profiles[0].date) + ")\n" +
373 332
                     "Value Area: " + DoubleToString(ValueAreaPercent, 0) + "%\n" +
374 333
                     "VAL: " + DoubleToString(g_Profiles[0].val, _Digits) + "\n" +
@@ -379,7 +338,24 @@ void CalculateAllVolumeProfiles()
379 338
       Comment(info);
380 339
      }
381 340
   }
382
-
341
+//+------------------------------------------------------------------+
342
+//|                                                                  |
343
+//+------------------------------------------------------------------+
344
+bool newDayBar()
345
+  {
346
+   static datetime lastbar;
347
+   datetime curbar = iTime(Symbol(), PERIOD_D1, 0);
348
+   if(lastbar != curbar)
349
+     {
350
+      lastbar = curbar;
351
+      Print(" ---------------------- New Day Bar :: ---------------------- ",lastbar);
352
+      return (true);
353
+     }
354
+   else
355
+     {
356
+      return (false);
357
+     }
358
+  }
383 359
 //+------------------------------------------------------------------+
384 360
 //| Calculate time boundaries for a profile                          |
385 361
 //+------------------------------------------------------------------+
@@ -420,8 +396,8 @@ void CalculateTimeBoundaries(int index)
420 396
    string dayBeforeTradingDayStr = StringFormat("%04d.%02d.%02d", beforeMdt.year, beforeMdt.mon, beforeMdt.day);
421 397
 
422 398
 // Calculate start and end times
423
-   g_Profiles[index].startTime = StringToTime(dayBeforeTradingDayStr + " 23:59:00");
424
-   g_Profiles[index].endTime = StringToTime(tradingDayStr + " 23:59:00");
399
+   g_Profiles[index].startTime = StringToTime(dayBeforeTradingDayStr + " 23:00:00");
400
+   g_Profiles[index].endTime = StringToTime(tradingDayStr + " 23:00:00");
425 401
    g_Profiles[index].displayStart = g_Profiles[index].endTime;
426 402
   }
427 403
 
@@ -436,7 +412,7 @@ void CalculateVolumeProfileForDay(int index)
436 412
 
437 413
    Print("Calculating volume profile for ", TimeToString(tradingDay, TIME_DATE),
438 414
          " (", GetDayOfWeekName(tradingDay), ")");
439
-   Print("Time range: ", TimeToString(startTime), " to ", TimeToString(endTime));
415
+   Print("Time range: ", TimeToString(startTime), " to ", TimeToString(endTime), " Index: ", index);
440 416
 
441 417
 // Copy the OHLCV data for this day - using M1 timeframe for precision
442 418
    MqlRates rates[];

BIN
valFvgMt5.ex5


+ 8 - 13
valFvgMt5.mq5

@@ -5,7 +5,7 @@
5 5
 //+------------------------------------------------------------------+
6 6
 #property copyright "Copyright 2025, MQL Development"
7 7
 #property link      "https://www.mqldevelopment.com/"
8
-#property version   "1.1"
8
+#property version   "1.2"
9 9
 #include <Trade\Trade.mqh>
10 10
 CTrade  trade;
11 11
 #resource "\\Indicators\\SequentialVolumeProfileWithFVG.ex5"
@@ -92,11 +92,6 @@ input        color                   BearishFVGColor            = clrDeepPink;
92 92
 input        double                  MinFVGSize                 = 0.0;              // Minimum FVG size in points (0 = any size)
93 93
 input        int                     MaxBarsBack                = 300;              // How many bars to look back for FVG
94 94
 
95
-input        string                  startHour                  = "23";             // Start Hour
96
-input        string                  startMin                   = "59";             // Start Minutes
97
-input        string                  endHour                    = "00";             // End Hour
98
-input        string                  endMin                     = "05";             // End Minutes
99
-
100 95
 
101 96
 
102 97
 // Global Variables
@@ -105,12 +100,16 @@ datetime  startTradingTime = 0, endTradingTime = 0;
105 100
 string sep  =  ":";                // A separator as a character
106 101
 ushort u_sep;                      // The code of the separator character
107 102
 string result1[];
103
+
108 104
 //+------------------------------------------------------------------+
109 105
 //|                                                                  |
110 106
 //+------------------------------------------------------------------+
111 107
 int OnInit()
112 108
   {
113 109
 //---
110
+
111
+
112
+     
114 113
    trade.SetExpertMagicNumber(magic_no);
115 114
    trade.SetDeviationInPoints(10);
116 115
    trade.SetTypeFilling(ORDER_FILLING_IOC);
@@ -138,11 +137,7 @@ int OnInit()
138 137
                                 BullishFVGColor,
139 138
                                 BearishFVGColor,
140 139
                                 MinFVGSize,
141
-                                MaxBarsBack,
142
-                                startHour,
143
-                                startMin,
144
-                                endHour,
145
-                                endMin);
140
+                                MaxBarsBack);
146 141
 
147 142
 
148 143
 //---
@@ -528,7 +523,7 @@ string check_bearish_bullish()
528 523
 string fvg_gap()
529 524
   {
530 525
 //Print("Imbalance: ");
531
-//  if(check_bearish_bullish() == previousBullish)
526
+ //  if(check_bearish_bullish() == previousBullish)
532 527
      {
533 528
       if(iLow(Symbol(), PERIOD_CURRENT, 1) > iHigh(Symbol(), PERIOD_CURRENT, 3))
534 529
         {
@@ -553,7 +548,7 @@ string fvg_gap()
553 548
            }
554 549
         }
555 550
      }
556
-// if(check_bearish_bullish() == previousBearish)
551
+  // if(check_bearish_bullish() == previousBearish)
557 552
      {
558 553
       if(iLow(Symbol(), PERIOD_CURRENT, 3) > iHigh(Symbol(), PERIOD_CURRENT, 1))
559 554
         {