|
|||||||
| 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 |
|
|||
|
Help!! simple color change indicator problem..
Anyone help with this?? I've spent the last three hours trying to make this indicator change the bar color when it is below 0. Green above 0, red below 0. I'm not very good with coding, so any help would be greatly appreciated, thanks!
Quote:
|
|
|||
|
Maybe you figured it out already but here's what I did neway:
//+------------------------------------------------------------------+ //| DiNapoli Detrend Oscillator.mq4 //| Ramdass - Conversion only //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Lime #property indicator_color2 Red extern int x_prd=14; extern int CountBars=3000; //---- buffers double dpo[], dpo2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- indicator line IndicatorBuffers(2); SetIndexBuffer(0,dpo); SetIndexBuffer(1,dpo2); //---- return(0); } //+------------------------------------------------------------------+ //| DPO | //+------------------------------------------------------------------+ int start() { //Putting the SetIndexStyle here allows the setting to remain after each time you re-compile //If you dont, the setting will only be applied if you reload the indicator (manually or from a saved template) SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 3, Lime); SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 3, Red); if (CountBars>=Bars) CountBars=Bars; SetIndexDrawBegin(0,Bars-CountBars+x_prd+1); int i,counted_bars=IndicatorCounted(); double t_prd; //---- if(Bars<=x_prd) return(0); //---- initial zero if(counted_bars<x_prd) { for(i=1;i<=x_prd;i++) dpo[CountBars-i]=0.0; } //---- i=CountBars-x_prd-1; t_prd=x_prd/2+1; double val = 0; while(i>=0) { val=Close[i]-iMA(NULL,0,7,MODE_SMA,0,PRICE_CLOSE,i); if (val >= 0) { dpo[i] = val; dpo2[i] = 0; } else if (val < 0) { dpo2[i] = val; dpo[i] = 0; } i--; } return(0); } //+------------------------------------------------------------------+ |
|
|||
|
How to reference the DiNapoli DPO in an expert?
Hello Jamrok,
This PM is concerning your post regarding the DiNapoli Detrend Price Oscillator. Hope you don't mind but thought you might not see the question if I posted it following your post of last May . I'm trying the reference the DiNap DPO from an expert but don't know how to configure the line of code that follows, 'iCustom'. Would you know what I would include? For example for reference to the custom indicator 'Stochastic DiNapoli" I would include the following; double stom1 = iCustom(NULL,0,"StochasticDiNapoli", 12,6,7,MODE_EMA,0,MODE_MAIN,1); On a related topic, do you know what phrase should be included in a similar expert reference to the 'Stochastic' indicator included with MT4, to require the Close/Close price field be used? It seems to default to low/high. If you can help it will be appreciated, - MJ P.S.- The copy of the DiNapoli Price Detrend indicator code is below. ---------------------------------------- //+------------------------------------------------------------------+ //| DiNapoli Detrend Oscillator.mq4 //| Treberk, www.forex-tsd.com - Conversion only //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Blue extern int x_prd=14; extern int CountBars=300; //---- buffers double dpo[]; extern int MAPeriod=7; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- indicator line IndicatorBuffers(1); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,dpo); //---- return(0); } //+------------------------------------------------------------------+ //| DPO | //+------------------------------------------------------------------+ int start() { if (CountBars>=Bars) CountBars=Bars; SetIndexDrawBegin(0,Bars-CountBars+x_prd+1); int i,counted_bars=IndicatorCounted(); //---- if(Bars<=x_prd) return(0); //---- initial zero if(counted_bars<x_prd) { for(i=1;i<=x_prd;i++) dpo[CountBars-i]=0.0; } //---- i=CountBars-x_prd-1; while(i>=0) { dpo[i]=Close[i]-iMA(NULL,0,MAPeriod,MODE_SMA,0,PRICE_CLOSE,i); i--; } return(0); } //+------------------------------------------------------------------+ |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to change the color of text in EA | fxwealth | Metatrader 4 | 4 | 06-07-2007 05:39 PM |
| Need help with simple EA problem - newbie | mikep | Metatrader 4 mql 4 - Development course | 7 | 12-15-2006 09:29 PM |
| color change | swall | Metatrader 4 | 2 | 10-25-2006 11:41 PM |
| Help: Indicator color change | asam | Indicators - Metatrader 4 | 2 | 10-24-2006 01:23 AM |