Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


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

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-10-2006, 07:02 PM
drgoodvibe drgoodvibe is offline
Senior Member
 
Join Date: Dec 2005
Location: Null
Posts: 534
drgoodvibe is on a distinguished road
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:

//+------------------------------------------------------------------+
//| DiNapoli Detrend Oscillator.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue



extern int x_prd=14;
extern int CountBars=3000;
//---- buffers
double dpo[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
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();
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;

while(i>=0)
{
dpo[i]=Close[i]-iMA(NULL,0,7,MODE_SMA,0,PRICE_CLOSE,i);


i--;
}
return(0);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-12-2006, 02:50 AM
jamrok jamrok is offline
Junior Member
 
Join Date: Nov 2005
Posts: 5
jamrok is on a distinguished road
Smile Only way I know how is to add another indicator buffer

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);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-12-2006, 01:32 PM
drgoodvibe drgoodvibe is offline
Senior Member
 
Join Date: Dec 2005
Location: Null
Posts: 534
drgoodvibe is on a distinguished road
no I was still having problems coding it, it just wasn't coming out right.. But this is PERFECT!! thank you very much!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-16-2006, 05:42 AM
marketjouster marketjouster is offline
Junior Member
 
Join Date: Nov 2005
Location: Amman, Jordan
Posts: 22
marketjouster is on a distinguished road
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);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


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


All times are GMT. The time now is 08:29 AM.