Forex
Google

Go Back   Forex Trading > Discussion Areas > Metatrader 4
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 12-09-2005, 06:21 PM
billm billm is offline
Member
 
Join Date: Dec 2005
Posts: 52
billm is on a distinguished road
How to change line colour

I am struggling with getting my coding to work.

If I am using an oscillator with 2 lines that moves around the zero line, how do I programme in MetaTrader4 for the line to change colour when line A is above line B and > zero line and similarly display a different colour when it is < zero ?

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-09-2005, 09:26 PM
keris2112's Avatar
keris2112 keris2112 is offline
Senior Member
 
Join Date: Dec 2005
Location: California, US
Posts: 129
keris2112 is on a distinguished road
Here's an example of the code I used to modify the colors in the shi_channel indicator. The channel color was green all the time. I modified it so that depending on if it was an up or down sloping channel, the color would either be green or red.

Take a look at the IF statement to see how I did it....

Code:
ObjectCreate("TL1",OBJ_TREND,0,T2,PP+Step*AB,T1,PP);
// Channel is Green if width is greater than ChannelAlert (Default 50),
// otherwise it is Red
if(ChannelWidth >= ChannelAlert) {ObjectSet("TL1",OBJPROP_COLOR,Lime);}
else {ObjectSet("TL1",OBJPROP_COLOR,Red); }
ObjectSet("TL1",OBJPROP_WIDTH,2); 
ObjectSet("TL1",OBJPROP_STYLE,STYLE_SOLID);
All you need to do is create an IF statement, and based on the outcome of the IF statement, the OBJPROP_COLOR will be set to this or that color.

Hope that helps.

Keris
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-09-2005, 09:27 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow

Quote:
Originally Posted by billm
I am struggling with getting my coding to work.

If I am using an oscillator with 2 lines that moves around the zero line, how do I programme in MetaTrader4 for the line to change colour when line A is above line B and > zero line and similarly display a different colour when it is < zero ?

thanks
billm,

Could we see the code?
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-10-2005, 05:39 PM
billm billm is offline
Member
 
Join Date: Dec 2005
Posts: 52
billm is on a distinguished road
Smile

thanks, I'll try that method

Do you know of a way of displaying 2 or more seperate indicators in the same window? eg; a line based indicator and a histogram, both using different code rather than trying to merge the 2 codes together ?

I'm just trying to make best use of screen space thats all

thanks
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
Rectangle object colour trevman Tools and utilities 1 03-15-2007 10:16 PM
Help with adding colour to TSI indicator drgoodvibe Indicators - Metatrader 4 3 11-26-2006 04:18 AM
How can I define Colour change babarmughal Expert Advisors - Metatrader 4 9 11-12-2006 04:19 PM
Global colour change - possible? niceguy777 Setup Questions 2 11-10-2006 12:15 AM


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