Rengoku Posted October 25, 2009 Report Share Posted October 25, 2009 Could someone please help me with iCustom indicator calls??? What I need is iCustom calls for each of the 4 lines on this indicator? For the Bulls Main line, Bears Main line, Bulls Signal line, and the Bears Signal line. I would really appreciate anyone’s help! Since i cannot upload it here i will just copy the code below... Thanks for your help! //+------------------------------------------------------------------+ //| AbsoluteStrength_v1.1.mq4 | //| Copyright © 2006, TrendLaboratory Ltd. | //| [url]http://finance.groups.yahoo.com/group/TrendLaboratory[/url] | //| E-mail: [email][email protected][/email] | //+------------------------------------------------------------------+ //mod. mtf standalone 2008fxtsd ki #property copyright "Copyright © 2006, TrendLaboratory Ltd." #property link "http://finance.groups.yahoo.com/group/TrendLaboratory" #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 CornflowerBlue #property indicator_width1 2 #property indicator_color2 OrangeRed #property indicator_width2 2 #property indicator_color3 DeepSkyBlue #property indicator_width3 1 #property indicator_style3 0 #property indicator_color4 Orange #property indicator_width4 1 #property indicator_style4 0 //---- input parameters extern int Length = 10; // Period of evaluation extern int Smooth = 5; // Period of smoothing extern int Signal = 5; // Period of Signal Line extern int MA_method = 3; // Mode of Moving Average extern int MA_Price = 0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted extern int AbS_Mode = 0; // 0-RSI method; 1-Stoch method; 2-ADX method extern bool UseOBOSLevels = false; extern double OverBoughtL = 80; // OverBought Level extern double OverSoldL = 20; // OverSold Level extern int MaxBarsToCount = 1500; extern int TimeFrame = 0; extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN"; extern string note_Price = "0C 1O 2H 3L 4Md 5Tp 6WghC, Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6"; extern string MA_Method_ = "SMA0 EMA1 SMMA2 LWMA3"; extern string AbS_Mode__ = "0-RSI 1-Stoch 2-ADX method"; string IndicatorFileName; int BarsToDraw; //---- buffers double Bulls[]; double Bears[]; double AvgBulls[]; double AvgBears[]; double SmthBulls[]; double SmthBears[]; double SigBulls[]; double SigBears[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(8); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,SmthBulls); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,SmthBears); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,SigBulls); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,SigBears); SetIndexBuffer(4,Bulls); SetIndexBuffer(5,Bears); SetIndexBuffer(6,AvgBulls); SetIndexBuffer(7,AvgBears); //---- switch(TimeFrame) { case 1: string TimeFrameStr = "M1"; break; case 5 : TimeFrameStr = "M5"; break; case 15 : TimeFrameStr = "M15"; break; case 30 : TimeFrameStr = "M30"; break; case 60 : TimeFrameStr = "H1"; break; case 240 : TimeFrameStr = "H4"; break; case 1440 : TimeFrameStr = "D1"; break; case 10080 : TimeFrameStr = "W1"; break; case 43200 : TimeFrameStr = "MN1"; break; default : TimeFrameStr = "TF0"; } switch(AbS_Mode) { case 1: string AbS_Mode_Str = "STOmode"; break; case 2 : AbS_Mode_Str = "ADXmode"; break; default : AbS_Mode_Str = "RSImode"; } //---- name for DataWindow and indicator subwindow label string short_name="AbsStr ["+TimeFrameStr+"] "+Length+","+Smooth+","+Signal+ " ("+MA_method+") "+AbS_Mode_Str+"|"; IndicatorShortName(short_name); IndicatorFileName = WindowExpertName(); SetIndexLabel(0,"Bulls"+short_name); SetIndexLabel(1,"Bears"+short_name); SetIndexLabel(2,"SignalBulls"+short_name); SetIndexLabel(3,"SignalBears"+short_name); int max = MathMax(Length,Smooth); max = MathMax(Signal,max); max = MathMax(TimeFrame/Period(),max); BarsToDraw = MaxBarsToCount-max; if (TimeFrame<Period()) TimeFrame=Period(); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int shift, counted_bars=IndicatorCounted(); double Price1, Price2, smax, smin; int limit,i; if(counted_bars < 0) return(-1); limit = Bars-counted_bars; if (TimeFrame != Period()) { limit = MathMax(limit,TimeFrame/Period()); // limit = MathMin(limit,MaxBarsToCount); datetime TimeArray[]; ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame); for(i=0,int y=0; i<limit; i++) { if(Time[i]<TimeArray[y]) y++; SmthBulls[i] = iCustom(NULL,TimeFrame,IndicatorFileName, Length,Smooth,Signal,MA_method,MA_Price,AbS_Mode, UseOBOSLevels,OverBoughtL,OverSoldL,MaxBarsToCount,0,y); SmthBears[i] = iCustom(NULL,TimeFrame,IndicatorFileName, Length,Smooth,Signal,MA_method,MA_Price,AbS_Mode, UseOBOSLevels,OverBoughtL,OverSoldL,MaxBarsToCount,1,y); SigBulls[i] = iCustom(NULL,TimeFrame,IndicatorFileName, Length,Smooth,Signal,MA_method,MA_Price,AbS_Mode, UseOBOSLevels,OverBoughtL,OverSoldL,MaxBarsToCount,2,y); SigBears[i] = iCustom(NULL,TimeFrame,IndicatorFileName, Length,Smooth,Signal,MA_method,MA_Price,AbS_Mode, UseOBOSLevels,OverBoughtL,OverSoldL,MaxBarsToCount,3,y); } return(0); } //---- if ( counted_bars < 0 ) return(-1); if ( counted_bars ==0 ) limit=Bars-Length+Smooth+Signal-1; if ( counted_bars < 1 ) for(i=1;i<Length+Smooth+Signal;i++) { Bulls[bars-i]=0; Bears[bars-i]=0; AvgBulls[bars-i]=0; AvgBears[bars-i]=0; SmthBulls[bars-i]=0; SmthBears[bars-i]=0; SigBulls[bars-i]=0; SigBears[bars-i]=0; } if(counted_bars>0) limit=Bars-counted_bars; limit--; for( shift=limit; shift>=0; shift--) { Price1 = iMA(NULL,0,1,0,0,MA_Price,shift); Price2 = iMA(NULL,0,1,0,0,MA_Price,shift+1); if (AbS_Mode>2) AbS_Mode=2; if (AbS_Mode==0) { Bulls[shift] = 0.5*(MathAbs(Price1-Price2)+(Price1-Price2)); Bears[shift] = 0.5*(MathAbs(Price1-Price2)-(Price1-Price2)); } if (AbS_Mode==1) { smax=High[Highest(NULL,0,MODE_HIGH,Length,shift)]; smin=Low[Lowest(NULL,0,MODE_LOW,Length,shift)]; Bulls[shift] = Price1 - smin; Bears[shift] = smax - Price1; } if (AbS_Mode==2) { Bulls[shift] = 0.5*(MathAbs(High[shift]-High[shift+1])+(High[shift]-High[shift+1])); Bears[shift] = 0.5*(MathAbs(Low[shift+1]-Low[shift])+(Low[shift+1]-Low[shift])); } } for( shift=limit; shift>=0; shift--) { AvgBulls[shift]=iMAOnArray(Bulls,0,Length,0,MA_method,shift); AvgBears[shift]=iMAOnArray(Bears,0,Length,0,MA_method,shift); } for( shift=limit; shift>=0; shift--) { SmthBulls[shift]=iMAOnArray(AvgBulls,0,Smooth,0,MA_method,shift); SmthBears[shift]=iMAOnArray(AvgBears,0,Smooth,0,MA_method,shift); } for( shift=limit; shift>=0; shift--) { if (UseOBOSLevels ) { SigBulls[shift]=OverBoughtL/100*(SmthBulls[shift]+SmthBears[shift]); SigBears[shift]=OverSoldL/100*(SmthBulls[shift]+SmthBears[shift]); } else { SigBulls[shift]=iMAOnArray(SmthBulls,0,Signal,0,MA_method,shift); SigBears[shift]=iMAOnArray(SmthBears,0,Signal,0,MA_method,shift); } } //---- // for (i=0;i<indicator_buffers;i++) SetIndexDrawBegin(i,Bars-BarsToDraw*TimeFrame/Period()); return(0); } //+------------------------------------------------------------------+ Quote Link to comment Share on other sites More sharing options...
San4x Posted October 26, 2009 Report Share Posted October 26, 2009 Re: iCustom help Try this: double bullsmain = iCustom(Symbol(),0,"AbsoluteStrength_v1.1",0,1); double bearsmain = iCustom(Symbol(),0,"AbsoluteStrength_v1.1",1,1); double bulls_sig = iCustom(Symbol(),0,"AbsoluteStrength_v1.1",2,1); double bears_sig = iCustom(Symbol(),0,"AbsoluteStrength_v1.1",3,1); The last "1" means it's calculated for the previous bar. This is the fastest way. If you want to declare/change variables in the EA itself for this indicator, then add those and don't forget to include them in the beginning of the EA. For more info see: http://docs.mql4.com/indicators/iCustom Hope this helps a bit. Quote Thanks for the kudos...much appreciated! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.