Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 05-10-2006, 08:02 PM
Senior Member
 
Join Date: Dec 2005
Location: Null
Posts: 585
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 05-12-2006, 03:50 AM
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 05-12-2006, 02:32 PM
Senior Member
 
Join Date: Dec 2005
Location: Null
Posts: 585
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 07-16-2006, 06:42 AM
Member
 
Join Date: Nov 2005
Location: Amman, Jordan
Posts: 33
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
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 06:39 PM
Need help with simple EA problem - newbie mikep Metatrader 4 mql 4 - Development course 7 12-15-2006 10:29 PM
color change swall Metatrader 4 2 10-26-2006 12:41 AM
Help: Indicator color change asam Indicators - Metatrader 4 2 10-24-2006 02:23 AM


All times are GMT. The time now is 02:16 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.