Explorar o código

Ticket: 4750 Complete

Huzaifa-MQLDev hai 7 meses
pai
achega
839cf7a356
Modificáronse 2 ficheiros con 26 adicións e 14 borrados
  1. BIN=BIN
      atr_momentum_indicator_mt4.ex4
  2. 26 14
      atr_momentum_indicator_mt4.mq4

BIN=BIN
atr_momentum_indicator_mt4.ex4


+ 26 - 14
atr_momentum_indicator_mt4.mq4

@@ -15,7 +15,7 @@
15 15
 //+------------------------------------------------------------------+
16 16
 
17 17
 input       string                string_1              = "<><><><><><> General SETTINGS <><><><><><>";   //__
18
-input       double                threshold             = 0.00001;          // Threshold Value
18
+input       double                threshold             = 30.0;          // Threshold Value
19 19
 
20 20
 sinput      string                atrSettings           = " <><><><><>  Atr Settings <><><><><>  "; //_
21 21
 input       int                   atrPeriod             = 14;            // ATR Period
@@ -80,32 +80,43 @@ int OnCalculate(const int rates_total,
80 80
       double candle_1 = iClose(Symbol(), PERIOD_CURRENT, 0 + 1);
81 81
       double candle_2 = iClose(Symbol(), PERIOD_CURRENT, 0 + 2);
82 82
 
83
-      double value_1 = ((atrPercentageValue(i + 1) - atrPercentageValue(i + 2)) / atrPercentageValue(i + 2));
84
-      double value_2 = ((atrPercentageValue(i) - atrPercentageValue(i + 1)) / atrPercentageValue(i + 1));
85
-      double value_3 = ((atrPercentageValue(i) - atrPercentageValue(i + 2)) / atrPercentageValue(i + 2));
83
+      double candle_percentage_0 = atrPercentageValue(i);
84
+      double candle_percentage_1 = atrPercentageValue(i + 1);
85
+      double candle_percentage_2 = atrPercentageValue(i + 2);
86 86
 
87
+      double value_1 = 0, value_2 = 0, value_3 = 0;
88
+
89
+      if(candle_percentage_0 != 0 && candle_percentage_1 != 0 && candle_percentage_2 != 0)
90
+        {
91
+         value_1 = (((candle_percentage_1 - candle_percentage_2) / candle_percentage_2) * 100);
92
+         value_2 = (((candle_percentage_0 - candle_percentage_1) / candle_percentage_1) * 100);
93
+         value_3 = (((candle_percentage_0 - candle_percentage_2) / candle_percentage_2) * 100);
94
+        }
87 95
       double totalSum = value_1 + value_2 + value_3;
88 96
 
89 97
       atrPercentageBuffer[i] = ((atrValueIs / candle_1) * 100);
98
+      atrPercentageBuffer[i] = atrPercentageBuffer[i] * 100;
90 99
 
91 100
       if(totalSum > threshold)
92 101
         {
93 102
          signalBuffer[i] = totalSum;
103
+         noSignalBuffer[i] = 0;
94 104
         }
95 105
       else
96 106
         {
97 107
          noSignalBuffer[i] = totalSum;
108
+         signalBuffer[i] = 0;
98 109
         }
99 110
 
100
-      Print("Time Current Candle: ", iClose(Symbol(), PERIOD_CURRENT,0),
101
-            " | Time Candle 1: ", iClose(Symbol(), PERIOD_CURRENT, 0 + 1),
102
-            " | Time Candle 2: ", iClose(Symbol(), PERIOD_CURRENT, 0 + 2),
103
-            " | ATR Value: ", atrValueIs,
104
-            " | value_1: ", value_1,
105
-            " | value_2: ", value_2,
106
-            " | value_3: ", value_3,
107
-            " | Sum: ", NormalizeDouble(totalSum, Digits()),
108
-            " | i: ", i);
111
+      //Print("Time Current Candle: ", iClose(Symbol(), PERIOD_CURRENT,0),
112
+      //      " | Time Candle 1: ", iClose(Symbol(), PERIOD_CURRENT, 0 + 1),
113
+      //      " | Time Candle 2: ", iClose(Symbol(), PERIOD_CURRENT, 0 + 2),
114
+      //      " | ATR Value: ", atrValueIs,
115
+      //      " | value_1: ", value_1,
116
+      //      " | value_2: ", value_2,
117
+      //      " | value_3: ", value_3,
118
+      //      " | Sum: ", NormalizeDouble(totalSum, Digits()),
119
+      //      " | i: ", i);
109 120
 
110 121
       i--;
111 122
      }
@@ -125,7 +136,8 @@ double atrValue(int index)
125 136
 //+------------------------------------------------------------------+
126 137
 double atrPercentageValue(int index)
127 138
   {
128
-   return (iATR(Symbol(), PERIOD_CURRENT, atrPeriod, index) / iClose(Symbol(), PERIOD_CURRENT, index)) * 100;
139
+// Print(" Atr Percentage: ", (iATR(Symbol(), PERIOD_CURRENT, atrPeriod, index) / iClose(Symbol(), PERIOD_CURRENT, index)) * 100, " i: ", index);
140
+   return (iATR(Symbol(), PERIOD_CURRENT, atrPeriod, index) / iClose(Symbol(), PERIOD_CURRENT, index + 1)) * 100;
129 141
   }
130 142
 //+------------------------------------------------------------------+
131 143
 //|                                                                  |