Conversion of indicator ADX(14) from the Metatrader4 trading software
Forums › ProRealTime English forum › ProBuilder support › Conversion of indicator ADX(14) from the Metatrader4 trading software
- This topic has 5 replies, 3 voices, and was last updated 4 years ago by highschool2005.
-
-
05/01/2020 at 5:56 PM #129280
Hi everyone,
I’m looking to add the DM+ and DM- with period 14 on close from Metatrader 4 to PRT. I found the ADX(14) on PRT but for some reasons, the indicator is different from the one on MT4. I would like someone to help me with the coding. They are almost the time so I’m sure it’s something small that must be tweaked but I have no idea what precisely. The most important to me is that both line cross each other at the same time.
05/01/2020 at 6:45 PM #129295It is most likely because the data it is applied to is different. If you are with IG then they have different candles to your MT4 feed. For example IG have six candle weeks on their daily charts as they have Sunday candles.
What you put in effects what you get out! 🙂
05/02/2020 at 9:34 AM #129345Thank you Vonasi for your reply. I am in fact looking at data from Tradersway on MT4 and data from Interactive Broker on PRT. So it makes sense that the graph is different. However I find it suspicious that my DM+ and DM- curves have such stronger movements on MT4 and are so much flater on PRT. As far as I know, it’s not possible to import data from Interactive Broker into MT4 or import data from Tradersway into PRT: this was an idea to doublecheck your hypothesis.
I will show you one area for example that’s very different to me compared to the chandeliers’ movements (there is one hour difference between both broker).
05/02/2020 at 12:27 PM #12938605/02/2020 at 2:04 PM #129413I found a similar indicator online with the same results in MQ4.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133//+------------------------------------------------------------------+//| average-directional-index.mq4 |//| ©2011 Best-metatrader-indicators.com. All rights reserved |//| http://www.best-metatrader-indicators.com |//+------------------------------------------------------------------+#property copyright "Copyright © 2011 Best-metatrader-indicators.com."#property link "http://www.best-metatrader-indicators.com"#property indicator_separate_window#property indicator_buffers 3#property indicator_color1 DodgerBlue#property indicator_color2 Tomato#property indicator_color3 Gold//---- input parametersextern int ADXPeriod=14;//---- buffersdouble ADXBuffer[];double PlusDiBuffer[];double MinusDiBuffer[];double PlusSdiBuffer[];double MinusSdiBuffer[];double TempBuffer[];string Copyright="\xA9 WWW.BEST-METATRADER-INDICATORS.COM";string MPrefix="FI";//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init(){//---- 3 additional buffers are used for counting.IndicatorBuffers(6);//---- indicator buffersSetIndexBuffer(0,ADXBuffer);SetIndexBuffer(1,PlusDiBuffer);SetIndexBuffer(2,MinusDiBuffer);SetIndexBuffer(3,PlusSdiBuffer);SetIndexBuffer(4,MinusSdiBuffer);SetIndexBuffer(5,TempBuffer);//---- name for DataWindow and indicator subwindow labelIndicatorShortName("ADX("+ADXPeriod+")");SetIndexLabel(0,"ADX");SetIndexLabel(1,"+DI");SetIndexLabel(2,"-DI");//----SetIndexDrawBegin(0,ADXPeriod);SetIndexDrawBegin(1,ADXPeriod);SetIndexDrawBegin(2,ADXPeriod);//----DL("001", Copyright, 5, 20,Gold,"Arial",10,0);return(0);}//+------------------------------------------------------------------+//| Custor indicator deinitialization function |//+------------------------------------------------------------------+int deinit(){//----ClearObjects();return(0);}//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int start(){double pdm,mdm,tr;double price_high,price_low;int starti,i,counted_bars=IndicatorCounted();//----i=Bars-2;PlusSdiBuffer[i+1]=0;MinusSdiBuffer[i+1]=0;if(counted_bars>=i) i=Bars-counted_bars-1;starti=i;//----while(i>=0){price_low=Low[i];price_high=High[i];//----pdm=price_high-High[i+1];mdm=Low[i+1]-price_low;if(pdm<0) pdm=0; // +DMif(mdm<0) mdm=0; // -DMif(pdm==mdm) { pdm=0; mdm=0; }else if(pdm<mdm) pdm=0;else if(mdm<pdm) mdm=0; //---- double num1=MathAbs(price_high-price_low); double num2=MathAbs(price_high-Close[i+1]); double num3=MathAbs(price_low-Close[i+1]); tr=MathMax(num1,num2); tr=MathMax(tr,num3); //---- counting plus/minus direction if(tr==0) { PlusSdiBuffer[i]=0; MinusSdiBuffer[i]=0; } else { PlusSdiBuffer[i]=100.0*pdm/tr; MinusSdiBuffer[i]=100.0*mdm/tr; } //---- i--; } //---- last counted bar will be recounted if(counted_bars>0) counted_bars--;int limit=Bars-counted_bars;//---- apply EMA to +DIfor(i=0; i<=limit; i++)PlusDiBuffer[i]=iMAOnArray(PlusSdiBuffer,Bars,ADXPeriod,0,MODE_EMA,i);//---- apply EMA to -DIfor(i=0; i<=limit; i++) MinusDiBuffer[i]=iMAOnArray(MinusSdiBuffer,Bars,ADXPeriod,0,MODE_EMA,i); //---- Directional Movement (DX) i=Bars-2; TempBuffer[i+1]=0; i=starti; while(i>=0){double div=MathAbs(PlusDiBuffer[i]+MinusDiBuffer[i]);if(div==0.00) TempBuffer[i]=0;else TempBuffer[i]=100*(MathAbs(PlusDiBuffer[i]-MinusDiBuffer[i])/div);i--;}//---- ADX is exponential moving average on DXfor(i=0; i<limit; i++)ADXBuffer[i]=iMAOnArray(TempBuffer,Bars,ADXPeriod,0,MODE_EMA,i);//----return(0);}//+------------------------------------------------------------------+//| DL function |//+------------------------------------------------------------------+void DL(string label, string text, int x, int y, color clr, string FontName = "Arial",int FontSize = 12, int typeCorner = 1){string labelIndicator = MPrefix + label;if (ObjectFind(labelIndicator) == -1){ObjectCreate(labelIndicator, OBJ_LABEL, 0, 0, 0);}ObjectSet(labelIndicator, OBJPROP_CORNER, typeCorner);ObjectSet(labelIndicator, OBJPROP_XDISTANCE, x);ObjectSet(labelIndicator, OBJPROP_YDISTANCE, y);ObjectSetText(labelIndicator, text, FontSize, FontName, clr);}//+------------------------------------------------------------------+//| ClearObjects function |//+------------------------------------------------------------------+void ClearObjects(){for(int i=0;i<ObjectsTotal();i++)if(StringFind(ObjectName(i),MPrefix)==0) { ObjectDelete(ObjectName(i)); i--; }}//+------------------------------------------------------------------+`
05/05/2020 at 8:29 AM #129968Hi everyone! Have you had time to check this code by any chance? Would like to get your opinion…
-
AuthorPosts
Find exclusive trading pro-tools on