Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.
backfoot
Members-
Content Count
5 -
Joined
-
Last visited
Personal Information
-
First Name
TradersLaboratory.com
-
Last Name
User
-
Country
Russian Federation
Trading Information
-
Vendor
No
-
Need to Rewrite Specific Macd from MQL or MultiChart for NT
backfoot replied to backfoot's topic in Automated Trading
and here... ... here is ... a mql... //+------------------------------------------------------------------+ //| Custom MACD.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Orange //---- indicator parameters extern int FastEMA=34; extern int SlowEMA=144; extern int SignalSMA=34; //---- indicator buffers double ind_buffer3[]; double ind_buffer4[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_HIST OGRAM,STYLE_SOLID,1); SetIndexStyle(1,DRAW_HIST OGRAM,STYLE_SOLID,1); // SetIndexDrawBegin(1,Signa lSMA); IndicatorDigits(MarketInf o(Symbol(),MODE_DIGITS)+1 ); //---- indicator buffers mapping if(!SetIndexBuffer(0,ind_ buffer3) && !SetIndexBuffer(1,ind_buf fer4)) Print("cannot set indicator buffers!"); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACDF orest("+FastEMA+","+SlowE MA+","+SignalSMA+")"); SetIndexLabel(0,"MACDfore st"); SetIndexLabel(1,"MACDfore st"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit,i; double MACDForestPre; int counted_bars=IndicatorCou nted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i=limit; i>=0; i--) { double MACDForest=iMACD(NULL,0,F astEMA,SlowEMA,SignalSMA, PRICE_MEDIAN,MODE_MAIN,i)-iMACD(NULL,0,FastEMA,Slow EMA,SignalSMA,PRICE_MEDIA N,MODE_SIGNAL,i); if (MACDForest>=MACDForestPr e) {ind_buffer3=MACDForest; ind_buffer4=EMPTY_VALUE;} if (MACDForest<MACDForestPre ) {ind_buffer4=MACDForest; ind_buffer3=EMPTY_VALUE;} MACDForestPre=MACDForest; } //---- done return(0); } ... thanks for response.. -
... here is ... a mql... //+------------------------------------------------------------------+ //| Custom MACD.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Orange //---- indicator parameters extern int FastEMA=34; extern int SlowEMA=144; extern int SignalSMA=34; //---- indicator buffers double ind_buffer3[]; double ind_buffer4[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1); // SetIndexDrawBegin(1,SignalSMA); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1); //---- indicator buffers mapping if(!SetIndexBuffer(0,ind_buffer3) && !SetIndexBuffer(1,ind_buffer4)) Print("cannot set indicator buffers!"); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACDForest("+FastEMA+","+SlowEMA+","+SignalSMA+")"); SetIndexLabel(0,"MACDforest"); SetIndexLabel(1,"MACDforest"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit,i; double MACDForestPre; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i=limit; i>=0; i--) { double MACDForest=iMACD(NULL,0,FastEMA,SlowEMA,SignalSMA,PRICE_MEDIAN,MODE_MAIN,i)-iMACD(NULL,0,FastEMA,SlowEMA,SignalSMA,PRICE_MEDIAN,MODE_SIGNAL,i); if (MACDForest>=MACDForestPre) {ind_buffer3=MACDForest; ind_buffer4=EMPTY_VALUE;} if (MACDForest<MACDForestPre) {ind_buffer4=MACDForest; ind_buffer3=EMPTY_VALUE;} MACDForestPre=MACDForest; } //---- done return(0); } ... thanks for response..
-
......and what language Ninja uses???
-
A specific macd need to write for NinjaTrader... in MT its name macdforest.... mayby anyone knows