Przeglądaj źródła

Ticket: 4436 Few Corrections in code

Huzaifa-MQLDev 1 rok temu
rodzic
commit
4802ccc574
2 zmienionych plików z 46 dodań i 31 usunięć
  1. BIN
      valFvgMt5.ex5
  2. 46 31
      valFvgMt5.mq5

BIN
valFvgMt5.ex5


+ 46 - 31
valFvgMt5.mq5

@@ -30,6 +30,11 @@ enum sl_options
    zone_based_sl,       // Zone Based Sl
    fvg_third,           // FVG third candle high and low + buffer
   };
+enum max_trades_option
+  {
+   one_trade,      // One Trade
+   one_buy_sell,   // One Buy One Sell
+  };
 
 sinput       string                  string_0                   = "<><><><><><> General SETTINGS <><><><><><>";   //__
 input        int                     magic_no                   = 333;             // Magic no
@@ -37,6 +42,7 @@ input        tp_options              select_tp                  = zone_based;
 input        sl_options              select_sl                  = zone_based_sl;   // Select Sl
 input        double                  stoploss                   = 4;               // FVG Third High/Low Stop Loss in Buffer
 input        double                  tpMultiplier               = 2;               // Take Profit Multiplier Risk to Reward
+input        max_trades_option       selectTradeCountOption     = one_trade;       // Select Max Trades at a Time
 
 input        string                  string_0_3                 = "<><><><><><> Lot Management<><><><><><>";   //__
 input        double                  lot_size                   = 0.1;             // Lot Size
@@ -48,13 +54,18 @@ input       bool                  EnableTimeFilter           = false;         //
 input       string                startTime                  = "03:00";       // Start Time Session
 input       string                endTime                    = "09:00";       // End Time Session
 
+input       string                fvg_setting                = "<><><><><> FVG Color Setting <><><><><>";             //_
+input       color                 bullish_color              = clrAqua;     // Bullish FVG Color
+input       color                 bearish_color              = clrYellow;   // Bearish FVG Color
+
+
 sinput       string                  string_1                   = "<><><><><><> Sequential Volume Indicator SETTINGS <><><><><><>";   //__
 input        int                     BinsCount                  = 100;              // Number of price bins
 input        double                  ValueAreaPercent           = 70;               // Value Area percentage (70% default)
-input        color                   VALColor                   = clrDarkBlue;      // Value Area Low color
-input        color                   VAHColor                   = clrDarkBlue;      // Value Area High color
-input        color                   AbsLowColor                = clrBlack;         // Absolute Low color
-input        color                   AbsHighColor               = clrBlack;         // Absolute High color
+input        color                   VALColor                   = clrYellow;        // Value Area Low color
+input        color                   VAHColor                   = clrYellow;        // Value Area High color
+input        color                   AbsLowColor                = clrDarkOrange;    // Absolute Low color
+input        color                   AbsHighColor               = clrDarkOrange;    // Absolute High color
 input        color                   TimeLineColor              = clrRed;           // Time marker line color
 input        int                     LineWidth                  = 2;                // Line width for all value lines
 input        int                     TimeLineWidth              = 2;                // Line width for time marker lines
@@ -65,15 +76,12 @@ input        ENUM_LINE_STYLE         AbsLowStyle                = STYLE_SOLID;
 input        ENUM_LINE_STYLE         AbsHighStyle               = STYLE_SOLID;      // Absolute High line style
 input        bool                    ShowLabels                 = true;             // Show price labels
 input        bool                    ShowComment                = true;             // Show comment with most recent levels
-input        bool                    ShowFVG                    = true;             // Enable Fair Value Gap detection
+input        bool                    ShowFVG                    = false;            // Enable Fair Value Gap detection
 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                fvg_setting                = "<><><><><> FVG Color Setting <><><><><>";             //_
-input       color                 bullish_color              = clrAqua;     // Bullish FVG Color
-input       color                 bearish_color              = clrYellow;   // Bearish FVG Color
 
 
 // Global Variables
@@ -127,7 +135,8 @@ int OnInit()
 void OnDeinit(const int reason)
   {
 //---
-
+   Print(" DeInIt ");
+   ObjectsDeleteAll(0, 0, OBJ_RECTANGLE);
   }
 //+------------------------------------------------------------------+
 //| Expert tick function                                             |
@@ -135,24 +144,26 @@ void OnDeinit(const int reason)
 void OnTick()
   {
 //---
-   double values[];
-   CopyBuffer(sequential_handler,0,0,3,values);
-   double val = lines("VAL");
-   double vah = lines("VAH");
-   double absHigh = lines("AbsHigh");
-   double absLow = lines("AbsLow");
+//   double values[];
+// CopyBuffer(sequential_handler,0,0,3,values);
 
 // Print("Val: ", val, "  Vah: ", vah, "  AbsHigh: ", absHigh, "  AbsLow: ", absLow);
-   double Ask = SymbolInfoDouble(Symbol(),SYMBOL_ASK);
-   double Bid = SymbolInfoDouble(Symbol(),SYMBOL_BID);
-   timeConversion();
+// double Ask = SymbolInfoDouble(Symbol(),SYMBOL_ASK);
+// double Bid = SymbolInfoDouble(Symbol(),SYMBOL_BID);
 
-   if((EnableTimeFilter && TimeCurrent() >= startTradingTime && TimeCurrent() < endTradingTime) ||  !EnableTimeFilter)
+   if(newBar())
      {
-      if(newBar())
+      timeConversion();
+
+      if((EnableTimeFilter && TimeCurrent() >= startTradingTime && TimeCurrent() < endTradingTime) ||  !EnableTimeFilter)
         {
+         double val = lines("VAL");
+         double vah = lines("VAH");
+         double absHigh = lines("AbsHigh");
+         double absLow = lines("AbsLow");
+
          string gapCreated = fvg_gap();
-         if(todayTradesCount(DEAL_TYPE_BUY) == 0)
+         if((selectTradeCountOption == one_buy_sell && todayTradesCount(DEAL_TYPE_BUY) == 0) || (selectTradeCountOption == one_trade && todayTradesCount(DEAL_TYPE_BUY) == 0 && todayTradesCount(DEAL_TYPE_SELL) == 0))
            {
             if(gapCreated == previousBullish)
               {
@@ -160,24 +171,28 @@ void OnTick()
                double close_2 = iClose(Symbol(), PERIOD_CURRENT, 2);
                double upper_price = MathMax(open_2, close_2);
                double lower_price = MathMin(open_2, close_2);
-               if(((upper_price > val) && (lower_price < val)) || ((upper_price < val) && (lower_price < val)))
-                 {
-                  placeBuyTrade();
-                 }
+               if(((upper_price < absHigh) && (lower_price < absHigh)))
+                  if(((upper_price > val) && (lower_price < val)) || ((upper_price < val) && (lower_price < val)))
+                    {
+                     Print("Buy Trade. Val: ", val, "  Vah: ", vah, "  AbsHigh: ", absHigh, "  AbsLow: ", absLow);
+                     placeBuyTrade();
+                    }
               }
            }
-         if(todayTradesCount(DEAL_TYPE_SELL) == 0)
+         if((selectTradeCountOption == one_buy_sell && todayTradesCount(DEAL_TYPE_SELL) == 0) || (selectTradeCountOption == one_trade && todayTradesCount(DEAL_TYPE_BUY) == 0 && todayTradesCount(DEAL_TYPE_SELL) == 0))
            {
             if(gapCreated == previousBearish)
               {
                double open_2 = iOpen(Symbol(), PERIOD_CURRENT, 2);
                double close_2 = iClose(Symbol(), PERIOD_CURRENT, 2);
                double upper_price = MathMax(open_2, close_2);
-               double lower_price = MathMin(open_2, close_2);  
-               if(((upper_price > vah) && (lower_price < vah)) || ((upper_price > vah) && (lower_price > vah)))
-                 {
-                  placeSellTrade();
-                 }
+               double lower_price = MathMin(open_2, close_2);
+               if(((upper_price > absLow) && (lower_price > absLow)))
+                  if(((upper_price > vah) && (lower_price < vah)) || ((upper_price > vah) && (lower_price > vah)))
+                    {
+                     Print("Sell Trade. Val: ", val, "  Vah: ", vah, "  AbsHigh: ", absHigh, "  AbsLow: ", absLow);
+                     placeSellTrade();
+                    }
               }
            }
         }