Little changes in TMA+CG.mq4 cause freezing mt4

1
Hi,

I only have added these lines to the TMA+CG mladen.mq4 indicator from @mladen. But when I add this new version to a chart mt4 freezes completely :(
What is wrong with it?

Code: Select all

--- C:\Users\Hermann\AppData\Roaming\MetaQuotes\Terminal\6757291BBE1793F2A78EDD4695819C20\MQL4\Indicators\TMA+CG mladen.mq4	2017-09-15 13:54:38.381000000 +0200
+++ C:\Users\Hermann\AppData\Roaming\MetaQuotes\Terminal\6757291BBE1793F2A78EDD4695819C20\MQL4\Indicators\TMA+CG mladen v1.01j.mq4	2017-09-19 11:02:01.189000000 +0200
@@ -22,6 +22,7 @@
 //
 //
 
+extern string Part_1          = "*** TMA settings ***";
 extern string TimeFrame       = "current time frame";
 extern int    HalfLength      = 56;
 //extern int    Price           = PRICE_WEIGHTED; //=0-6 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED
@@ -35,6 +36,11 @@
 extern bool   alertsSound     = false;
 extern bool   alertsEmail     = false;
 extern bool   Chart_to_front  = false;
+extern string Part_2          = "*** Arrows only when above/below MA ***";
+extern bool   Arrows_based_on_MA_Filter  = true;
+extern int    MA_Filter_Period= 120;
+extern ENUM_APPLIED_PRICE MA_Filter_Price = PRICE_CLOSE;
+extern ENUM_MA_METHOD MA_Filter_Method = MODE_SMMA;
 
 //
 //
@@ -60,7 +66,7 @@
 bool   calculatingTma = false;
 bool   returningBars  = false;
 int    timeFrame;
-
+double Smoothed_MA_value;
 //+------------------------------------------------------------------+
 //|                                                                  |
 //+------------------------------------------------------------------+
@@ -147,11 +153,27 @@
          upBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,"calculateTma",HalfLength,Price,BandsDeviations,1,shift1);
          dnBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,"calculateTma",HalfLength,Price,BandsDeviations,2,shift1);
 
-         upArrow[i] = EMPTY_VALUE;
-         dnArrow[i] = EMPTY_VALUE;            
-            if (High[i+1]>upBuffer[i+1] && Close[i+1]>Open[i+1] && Close[i]<Open[i]) upArrow[i] = High[i]+iATR(NULL,0,20,i);
-            if ( Low[i+1]<dnBuffer[i+1] && Close[i+1]<Open[i+1] && Close[i]>Open[i]) dnArrow[i] = High[i]-iATR(NULL,0,20,i)*2;
-
+         upArrow[i] = EMPTY_VALUE; //short arrow
+         dnArrow[i] = EMPTY_VALUE; //long arrow  
+         
+         Smoothed_MA_value = iMA(NULL,0,MA_Filter_Period,0,MA_Filter_Method,MA_Filter_Price,i+1);
+
+         if (!Arrows_based_on_MA_Filter) {
+            if (High[i+1]>upBuffer[i+1] && Close[i+1]>Open[i+1] && Close[i]<Open[i]) 
+               upArrow[i] = High[i]+iATR(NULL,0,20,i);
+            if (Low[i+1]<dnBuffer[i+1] && Close[i+1]<Open[i+1] && Close[i]>Open[i]) 
+               dnArrow[i] = High[i]-iATR(NULL,0,20,i)*2;
+         } else {
+            if ((High[i+1]>upBuffer[i+1] && Close[i+1]>Open[i+1] && Close[i]<Open[i]) 
+                  && (Close[i+1]<Smoothed_MA_value)) {
+                     upArrow[i] = High[i]+iATR(NULL,0,20,i);
+            }
+            if ((Low[i+1]<dnBuffer[i+1] && Close[i+1]<Open[i+1] && Close[i]>Open[i]) 
+                  && (Close[i+1]>Smoothed_MA_value)) {
+                     dnArrow[i] = High[i]-iATR(NULL,0,20,i)*2;
+            }
+         }
+            
          if (timeFrame <= Period() || shift1==iBarShift(NULL,timeFrame,Time[i-1])) continue;
          if (!Interpolate) continue;
 
What I try to do is only show the buy arrows (at bottom tma) when the price is above 120 MA value and vice versa.

Attached is my modified mt4 version.

Thanks!


Re: Little changes in TMA+CG.mq4 cause freezing mt4

2
I breaked it down line by line for my litle changes I made....

And whenever I add a new simple extern string variable like this

Code: Select all

extern string Part_1               = "*** TMA settings ***";
as first extern parameter in front of

Code: Select all

extern string TimeFrame       = "current time frame";
mt4 freezes when I add the indicator.

When I don't add this line everything is ok.

I don't understand this, is this the next mt4 bug with this latest version? :wtf: :yawn: :(

Re: Little changes in TMA+CG.mq4 cause freezing mt4

3
Jagg wrote: Thu Sep 21, 2017 6:38 pm I breaked it down line by line for my litle changes I made....

And whenever I add a new simple extern string variable like this

Code: Select all

extern string Part_1               = "*** TMA settings ***";
as first extern parameter in front of

Code: Select all

extern string TimeFrame       = "current time frame";
mt4 freezes when I add the indicator.

When I don't add this line everything is ok.

I don't understand this, is this the next mt4 bug with this latest version? :wtf: :yawn: :(
Metatrader passes arguments by position, not by name
Hence if you omit some of the parameters in the beginning of the parameters list, you are causing a confusion. Always use parameters (even if they are dummy parameters) that are listed in the parameters before the parameter of your interest (the one that you are actually using)


Who is online

Users browsing this forum: No registered users and 17 guests