Kaynağa Gözat

Ticket: 4750 Complete

Huzaifa-MQLDev 7 ay önce
ebeveyn
işleme
839cf7a356
2 değiştirilmiş dosya ile 26 ekleme ve 14 silme
  1. BIN
      atr_momentum_indicator_mt4.ex4
  2. 26 14
      atr_momentum_indicator_mt4.mq4

BIN
atr_momentum_indicator_mt4.ex4


+ 26 - 14
atr_momentum_indicator_mt4.mq4

@@ -15,7 +15,7 @@
15
 //+------------------------------------------------------------------+
15
 //+------------------------------------------------------------------+
16
 
16
 
17
 input       string                string_1              = "<><><><><><> General SETTINGS <><><><><><>";   //__
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
 sinput      string                atrSettings           = " <><><><><>  Atr Settings <><><><><>  "; //_
20
 sinput      string                atrSettings           = " <><><><><>  Atr Settings <><><><><>  "; //_
21
 input       int                   atrPeriod             = 14;            // ATR Period
21
 input       int                   atrPeriod             = 14;            // ATR Period
@@ -80,32 +80,43 @@ int OnCalculate(const int rates_total,
80
       double candle_1 = iClose(Symbol(), PERIOD_CURRENT, 0 + 1);
80
       double candle_1 = iClose(Symbol(), PERIOD_CURRENT, 0 + 1);
81
       double candle_2 = iClose(Symbol(), PERIOD_CURRENT, 0 + 2);
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
       double totalSum = value_1 + value_2 + value_3;
95
       double totalSum = value_1 + value_2 + value_3;
88
 
96
 
89
       atrPercentageBuffer[i] = ((atrValueIs / candle_1) * 100);
97
       atrPercentageBuffer[i] = ((atrValueIs / candle_1) * 100);
98
+      atrPercentageBuffer[i] = atrPercentageBuffer[i] * 100;
90
 
99
 
91
       if(totalSum > threshold)
100
       if(totalSum > threshold)
92
         {
101
         {
93
          signalBuffer[i] = totalSum;
102
          signalBuffer[i] = totalSum;
103
+         noSignalBuffer[i] = 0;
94
         }
104
         }
95
       else
105
       else
96
         {
106
         {
97
          noSignalBuffer[i] = totalSum;
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
       i--;
121
       i--;
111
      }
122
      }
@@ -125,7 +136,8 @@ double atrValue(int index)
125
 //+------------------------------------------------------------------+
136
 //+------------------------------------------------------------------+
126
 double atrPercentageValue(int index)
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
 //|                                                                  |