Kaynağa Gözat

Ticket: 4436 Few Corrections in code

Huzaifa-MQLDev 9 ay önce
ebeveyn
işleme
4802ccc574
2 değiştirilmiş dosya ile 46 ekleme ve 31 silme
  1. BIN
      valFvgMt5.ex5
  2. 46 31
      valFvgMt5.mq5

BIN
valFvgMt5.ex5


+ 46 - 31
valFvgMt5.mq5

@@ -30,6 +30,11 @@ enum sl_options
30 30
    zone_based_sl,       // Zone Based Sl
31 31
    fvg_third,           // FVG third candle high and low + buffer
32 32
   };
33
+enum max_trades_option
34
+  {
35
+   one_trade,      // One Trade
36
+   one_buy_sell,   // One Buy One Sell
37
+  };
33 38
 
34 39
 sinput       string                  string_0                   = "<><><><><><> General SETTINGS <><><><><><>";   //__
35 40
 input        int                     magic_no                   = 333;             // Magic no
@@ -37,6 +42,7 @@ input        tp_options              select_tp                  = zone_based;
37 42
 input        sl_options              select_sl                  = zone_based_sl;   // Select Sl
38 43
 input        double                  stoploss                   = 4;               // FVG Third High/Low Stop Loss in Buffer
39 44
 input        double                  tpMultiplier               = 2;               // Take Profit Multiplier Risk to Reward
45
+input        max_trades_option       selectTradeCountOption     = one_trade;       // Select Max Trades at a Time
40 46
 
41 47
 input        string                  string_0_3                 = "<><><><><><> Lot Management<><><><><><>";   //__
42 48
 input        double                  lot_size                   = 0.1;             // Lot Size
@@ -48,13 +54,18 @@ input       bool                  EnableTimeFilter           = false;         //
48 54
 input       string                startTime                  = "03:00";       // Start Time Session
49 55
 input       string                endTime                    = "09:00";       // End Time Session
50 56
 
57
+input       string                fvg_setting                = "<><><><><> FVG Color Setting <><><><><>";             //_
58
+input       color                 bullish_color              = clrAqua;     // Bullish FVG Color
59
+input       color                 bearish_color              = clrYellow;   // Bearish FVG Color
60
+
61
+
51 62
 sinput       string                  string_1                   = "<><><><><><> Sequential Volume Indicator SETTINGS <><><><><><>";   //__
52 63
 input        int                     BinsCount                  = 100;              // Number of price bins
53 64
 input        double                  ValueAreaPercent           = 70;               // Value Area percentage (70% default)
54
-input        color                   VALColor                   = clrDarkBlue;      // Value Area Low color
55
-input        color                   VAHColor                   = clrDarkBlue;      // Value Area High color
56
-input        color                   AbsLowColor                = clrBlack;         // Absolute Low color
57
-input        color                   AbsHighColor               = clrBlack;         // Absolute High color
65
+input        color                   VALColor                   = clrYellow;        // Value Area Low color
66
+input        color                   VAHColor                   = clrYellow;        // Value Area High color
67
+input        color                   AbsLowColor                = clrDarkOrange;    // Absolute Low color
68
+input        color                   AbsHighColor               = clrDarkOrange;    // Absolute High color
58 69
 input        color                   TimeLineColor              = clrRed;           // Time marker line color
59 70
 input        int                     LineWidth                  = 2;                // Line width for all value lines
60 71
 input        int                     TimeLineWidth              = 2;                // Line width for time marker lines
@@ -65,15 +76,12 @@ input        ENUM_LINE_STYLE         AbsLowStyle                = STYLE_SOLID;
65 76
 input        ENUM_LINE_STYLE         AbsHighStyle               = STYLE_SOLID;      // Absolute High line style
66 77
 input        bool                    ShowLabels                 = true;             // Show price labels
67 78
 input        bool                    ShowComment                = true;             // Show comment with most recent levels
68
-input        bool                    ShowFVG                    = true;             // Enable Fair Value Gap detection
79
+input        bool                    ShowFVG                    = false;            // Enable Fair Value Gap detection
69 80
 input        color                   BullishFVGColor            = clrLime;          // Bullish FVG color
70 81
 input        color                   BearishFVGColor            = clrDeepPink;      // Bearish FVG color
71 82
 input        double                  MinFVGSize                 = 0.0;              // Minimum FVG size in points (0 = any size)
72 83
 input        int                     MaxBarsBack                = 300;              // How many bars to look back for FVG
73 84
 
74
-input       string                fvg_setting                = "<><><><><> FVG Color Setting <><><><><>";             //_
75
-input       color                 bullish_color              = clrAqua;     // Bullish FVG Color
76
-input       color                 bearish_color              = clrYellow;   // Bearish FVG Color
77 85
 
78 86
 
79 87
 // Global Variables
@@ -127,7 +135,8 @@ int OnInit()
127 135
 void OnDeinit(const int reason)
128 136
   {
129 137
 //---
130
-
138
+   Print(" DeInIt ");
139
+   ObjectsDeleteAll(0, 0, OBJ_RECTANGLE);
131 140
   }
132 141
 //+------------------------------------------------------------------+
133 142
 //| Expert tick function                                             |
@@ -135,24 +144,26 @@ void OnDeinit(const int reason)
135 144
 void OnTick()
136 145
   {
137 146
 //---
138
-   double values[];
139
-   CopyBuffer(sequential_handler,0,0,3,values);
140
-   double val = lines("VAL");
141
-   double vah = lines("VAH");
142
-   double absHigh = lines("AbsHigh");
143
-   double absLow = lines("AbsLow");
147
+//   double values[];
148
+// CopyBuffer(sequential_handler,0,0,3,values);
144 149
 
145 150
 // Print("Val: ", val, "  Vah: ", vah, "  AbsHigh: ", absHigh, "  AbsLow: ", absLow);
146
-   double Ask = SymbolInfoDouble(Symbol(),SYMBOL_ASK);
147
-   double Bid = SymbolInfoDouble(Symbol(),SYMBOL_BID);
148
-   timeConversion();
151
+// double Ask = SymbolInfoDouble(Symbol(),SYMBOL_ASK);
152
+// double Bid = SymbolInfoDouble(Symbol(),SYMBOL_BID);
149 153
 
150
-   if((EnableTimeFilter && TimeCurrent() >= startTradingTime && TimeCurrent() < endTradingTime) ||  !EnableTimeFilter)
154
+   if(newBar())
151 155
      {
152
-      if(newBar())
156
+      timeConversion();
157
+
158
+      if((EnableTimeFilter && TimeCurrent() >= startTradingTime && TimeCurrent() < endTradingTime) ||  !EnableTimeFilter)
153 159
         {
160
+         double val = lines("VAL");
161
+         double vah = lines("VAH");
162
+         double absHigh = lines("AbsHigh");
163
+         double absLow = lines("AbsLow");
164
+
154 165
          string gapCreated = fvg_gap();
155
-         if(todayTradesCount(DEAL_TYPE_BUY) == 0)
166
+         if((selectTradeCountOption == one_buy_sell && todayTradesCount(DEAL_TYPE_BUY) == 0) || (selectTradeCountOption == one_trade && todayTradesCount(DEAL_TYPE_BUY) == 0 && todayTradesCount(DEAL_TYPE_SELL) == 0))
156 167
            {
157 168
             if(gapCreated == previousBullish)
158 169
               {
@@ -160,24 +171,28 @@ void OnTick()
160 171
                double close_2 = iClose(Symbol(), PERIOD_CURRENT, 2);
161 172
                double upper_price = MathMax(open_2, close_2);
162 173
                double lower_price = MathMin(open_2, close_2);
163
-               if(((upper_price > val) && (lower_price < val)) || ((upper_price < val) && (lower_price < val)))
164
-                 {
165
-                  placeBuyTrade();
166
-                 }
174
+               if(((upper_price < absHigh) && (lower_price < absHigh)))
175
+                  if(((upper_price > val) && (lower_price < val)) || ((upper_price < val) && (lower_price < val)))
176
+                    {
177
+                     Print("Buy Trade. Val: ", val, "  Vah: ", vah, "  AbsHigh: ", absHigh, "  AbsLow: ", absLow);
178
+                     placeBuyTrade();
179
+                    }
167 180
               }
168 181
            }
169
-         if(todayTradesCount(DEAL_TYPE_SELL) == 0)
182
+         if((selectTradeCountOption == one_buy_sell && todayTradesCount(DEAL_TYPE_SELL) == 0) || (selectTradeCountOption == one_trade && todayTradesCount(DEAL_TYPE_BUY) == 0 && todayTradesCount(DEAL_TYPE_SELL) == 0))
170 183
            {
171 184
             if(gapCreated == previousBearish)
172 185
               {
173 186
                double open_2 = iOpen(Symbol(), PERIOD_CURRENT, 2);
174 187
                double close_2 = iClose(Symbol(), PERIOD_CURRENT, 2);
175 188
                double upper_price = MathMax(open_2, close_2);
176
-               double lower_price = MathMin(open_2, close_2);  
177
-               if(((upper_price > vah) && (lower_price < vah)) || ((upper_price > vah) && (lower_price > vah)))
178
-                 {
179
-                  placeSellTrade();
180
-                 }
189
+               double lower_price = MathMin(open_2, close_2);
190
+               if(((upper_price > absLow) && (lower_price > absLow)))
191
+                  if(((upper_price > vah) && (lower_price < vah)) || ((upper_price > vah) && (lower_price > vah)))
192
+                    {
193
+                     Print("Sell Trade. Val: ", val, "  Vah: ", vah, "  AbsHigh: ", absHigh, "  AbsLow: ", absLow);
194
+                     placeSellTrade();
195
+                    }
181 196
               }
182 197
            }
183 198
         }