|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Quote:
|
|
||||
|
Quote:
Hi Coder's Guru, and how can I use the iMA function, not with a price, as the media of another indicator? like for example the media of RSI... Thank you |
|
|||
|
CodersGuru
Hi
Thank you for all the free info, it really helps a newbie like me a lot. I will appreciate it if you can explain the I icustom-function a bit more in detail. I try to put a function together for the attached indicators but must do something wrong. You will see that these two indicators do not have the same amount of info to be use in the icustom-function which still confuse me .I am not sure in what sequence to build the function . If possible can you post the icustom- function here and explain how you get to them. Regards Chris |
|
|||
|
CodersGuru
I could not get the indicators to attached.I will post them here:
1) //| ZeroLag MACD.mq4 | //| RD | //| marynarz15@wp.pl | //+------------------------------------------------------------------+ #property copyright "RD" #property link "marynarz15@wp.pl" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Magenta #property indicator_color2 Orange //---- input parameters extern int FastEMA=12; extern int SlowEMA=24; extern int SignalEMA=9; //---- buffers double MACDBuffer[]; double SignalBuffer[]; double FastEMABuffer[]; double SlowEMABuffer[]; double SignalEMABuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(5); SetIndexBuffer(0,MACDBuffer); SetIndexBuffer(1,SignalBuffer); SetIndexBuffer(2,FastEMABuffer); SetIndexBuffer(3,SlowEMABuffer); SetIndexBuffer(4,SignalEMABuffer); SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2); SetIndexStyle(1,DRAW_LINE,EMPTY,2); SetIndexDrawBegin(0,SlowEMA); SetIndexDrawBegin(1,SlowEMA); IndicatorShortName("ZeroLag MACD("+FastEMA+","+SlowEMA+","+SignalEMA+")"); SetIndexLabel(0,"MACD"); SetIndexLabel(1,"Signal"); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; double EMA,ZeroLagEMAp,ZeroLagEMAq; for(int i=0; i<limit; i++) { FastEMABuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i); SlowEMABuffer[i]=iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); } for(i=0; i<limit; i++) { EMA=iMAOnArray(FastEMABuffer,Bars,FastEMA,0,MODE_E MA,i); ZeroLagEMAp=FastEMABuffer[i]+FastEMABuffer[i]-EMA; EMA=iMAOnArray(SlowEMABuffer,Bars,SlowEMA,0,MODE_E MA,i); ZeroLagEMAq=SlowEMABuffer[i]+SlowEMABuffer[i]-EMA; MACDBuffer[i]=ZeroLagEMAp - ZeroLagEMAq; } for(i=0; i<limit; i++) SignalEMABuffer[i]=iMAOnArray(MACDBuffer,Bars,SignalEMA,0,MODE_EMA,i ); for(i=0; i<limit; i++) { EMA=iMAOnArray(SignalEMABuffer,Bars,SignalEMA,0,MO DE_EMA,i); SignalBuffer[i]=SignalEMABuffer[i]+SignalEMABuffer[i]-EMA; } return(0); } //+------------------------------------------------------------------+ 2)//+------------------------------------------------------------------+ //| Digital MACD.mq4 | //| Digital MACD rewritten by CrazyChart | //| | //+------------------------------------------------------------------+ #property copyright "Digital MACD rewritten by CrazyChart" #property link " " #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 YellowGreen #property indicator_color2 White //---- input parameters extern int CountBars=300; extern int SignalMAPeriod=5; //---- buffers double ExtGraph[]; double ExtSignal[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,ExtGraph); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtSignal); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- TODO: add your code here int shift,cnt,loop,AccountedBars; double value1,value2,AVG; bool firstTime=true; if (firstTime) { AccountedBars = Bars-CountBars; loop = CountBars-SignalMAPeriod-1; firstTime=false; } for (shift=Bars-2;shift>=0;shift--) { value1 = 0.2149840610*Close[shift+0] +0.2065763732*Close[shift+1] +0.1903728890*Close[shift+2] +0.1675422436*Close[shift+3] +0.1397053150*Close[shift+4] +0.1087951881*Close[shift+5] +0.0768869405*Close[shift+6] +0.0460244906*Close[shift+7] +0.0180517395*Close[shift+8] -0.0055294579*Close[shift+9] -0.0236660212*Close[shift+10] -0.0358140055*Close[shift+11] -0.0419497760*Close[shift+12] -0.0425331450*Close[shift+13] -0.0384279507*Close[shift+14] -0.0307917433*Close[shift+15] -0.0209443384*Close[shift+16] -0.0102335925*Close[shift+17] +0.0000932767*Close[shift+18] +0.0089950015*Close[shift+19] +0.0157131144*Close[shift+20] +0.0198149331*Close[shift+21] +0.0211989019*Close[shift+22] +0.0200639819*Close[shift+23] +0.0168532934*Close[shift+24] +0.0121825067*Close[shift+25] +0.0067474241*Close[shift+26] +0.0012444305*Close[shift+27] -0.0037087682*Close[shift+28] -0.0076300416*Close[shift+29] -0.0102110543*Close[shift+30] -0.0113306266*Close[shift+31] -0.0110462105*Close[shift+32] -0.0095662166*Close[shift+33] -0.0072080453*Close[shift+34] -0.0043494435*Close[shift+35] -0.0013771970*Close[shift+36] +0.0013575268*Close[shift+37] +0.0035760416*Close[shift+38] +0.0050946166*Close[shift+39] +0.0058339574*Close[shift+40] +0.0058160431*Close[shift+41] +0.0051486631*Close[shift+42] +0.0039984014*Close[shift+43] +0.0025619380*Close[shift+44] +0.0010531475*Close[shift+45] -0.0003481453*Close[shift+46] -0.0014937154*Close[shift+47] -0.0022905986*Close[shift+48] -0.0027000514*Close[shift+49] -0.0027359080*Close[shift+50] -0.0024543322*Close[shift+51] -0.0019409837*Close[shift+52] -0.0012957482*Close[shift+53] -0.0006179734*Close[shift+54] +0.0000057542*Close[shift+55] +0.0005111297*Close[shift+56] +0.0008605279*Close[shift+57] +0.0010441921*Close[shift+58] +0.0010775684*Close[shift+59] +0.0009966494*Close[shift+60] +0.0008537300*Close[shift+61] +0.0007142855*Close[shift+62] +0.0006599146*Close[shift+63] -0.0008151017*Close[shift+64]; value2 = 0.0825641231*Close[shift+0] +0.0822783080*Close[shift+1] +0.0814249974*Close[shift+2] +0.0800166909*Close[shift+3] +0.0780735197*Close[shift+4] +0.0756232268*Close[shift+5] +0.0727009740*Close[shift+6] +0.0693478349*Close[shift+7] +0.0656105823*Close[shift+8] +0.0615409157*Close[shift+9] +0.0571939540*Close[shift+10] +0.0526285643*Close[shift+11] +0.0479025123*Close[shift+12] +0.0430785482*Close[shift+13] +0.0382152880*Close[shift+14] +0.0333706133*Close[shift+15] +0.0286021160*Close[shift+16] +0.0239614376*Close[shift+17] +0.0194972056*Close[shift+18] +0.0152532583*Close[shift+19] +0.0112682658*Close[shift+20] +0.0075745482*Close[shift+21] +0.0041980052*Close[shift+22] +0.0011588603*Close[shift+23] -0.0015292889*Close[shift+24] -0.0038593393*Close[shift+25] -0.0058303888*Close[shift+26] -0.0074473108*Close[shift+27] -0.0087203043*Close[shift+28] -0.0096645874*Close[shift+29] -0.0102995666*Close[shift+30] -0.0106483424*Close[shift+31] -0.0107374524*Close[shift+32] -0.0105952115*Close[shift+33] -0.0102516944*Close[shift+34] -0.0097377645*Close[shift+35] -0.0090838346*Close[shift+36] -0.0083237046*Close[shift+37] -0.0074804382*Close[shift+38] -0.0065902734*Close[shift+39] -0.0056742995*Close[shift+40] -0.0047554314*Close[shift+41] -0.0038574209*Close[shift+42] -0.0029983549*Close[shift+43] -0.0021924972*Close[shift+44] -0.0014513858*Close[shift+45] -0.0007848072*Close[shift+46] -0.0001995891*Close[shift+47] +0.0003009728*Close[shift+48] +0.0007162164*Close[shift+49] +0.0010478905*Close[shift+50] +0.0012994016*Close[shift+51] +0.0014755433*Close[shift+52] +0.0015824007*Close[shift+53] +0.0016272598*Close[shift+54] +0.0016185271*Close[shift+55] +0.0015648336*Close[shift+56] +0.0014747659*Close[shift+57] +0.0013569946*Close[shift+58] +0.0012193896*Close[shift+59] +0.0010695971*Close[shift+60] +0.0009140878*Close[shift+61] +0.0007591540*Close[shift+62] +0.0016019033*Close[shift+63]; ExtGraph[shift]=value1-value2; if (shift>0) AccountedBars=AccountedBars+1; } for (shift=loop;shift>=0;shift--) { AVG = 0; for (cnt=0;cnt<=SignalMAPeriod-1;cnt++) { AVG = AVG + ExtGraph[shift+cnt]; } ExtSignal[shift]=AVG/SignalMAPeriod; if (shift>0) loop = loop-1; } //---- return(0); } //+------------------------------------------------------------------+ |
|
|||
|
Quote:
I know icustom, I know MACD but it is nothing in this indicator concerning "PRICE_CLOSE, MODE_SIGNAL" and so on. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with adding colour to TSI indicator | drgoodvibe | Indicators - Metatrader 4 | 3 | 11-26-2006 04:18 AM |
| Adding MA to an Indicator | PeaceLover | Metatrader 4 | 10 | 09-18-2006 06:18 PM |
| Adding Custom Indicator to Expert | Chewbaca | Expert Advisors - Metatrader 4 | 1 | 04-14-2006 09:36 AM |
| Help adding OBJ_TREND to indicator | nicugh | Setup Questions | 0 | 02-03-2006 06:18 PM |