Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1957

 
Buckets #: This is one of the combinations I tried.
Do not post code that will not even compile.
 
Buckets #:

I need some help, please.

I want to allow a user to change the colours of trendlines to his preferred colours.

I have tried various combinations of ENUM_OBJECT_PROPERTY_INTEGER, OBJPROP_COLOR and clrRed (for example) but I can't get it to work.

Could somebody help me with the correct code, please? 

Many thanks,

.

try this , i assume the objects exist and you have control of them :)

//input of the user , you want them to select a color so the type is color
input color myLinesColor=clrAliceBlue;//this text shows up in their inputs tab
/*
set your line colors like this :
suppose name is the name of the object in your code 
you tell the program to get that object and change its color property to 
what the user entered so :
*/
ObjectSetInteger(ChartID(),name,OBJPROP_COLOR,myLinesColor);
 

@Buckets #: I need some help, please. I want to allow a user to change the colours of trendlines to his preferred colours. I have tried various combinations of ENUM_OBJECT_PROPERTY_INTEGER, OBJPROP_COLOR and clrRed (for example) but I can't get it to work. Could somebody help me with the correct code, please? Many thanks. ... This is one of the combinations I tried.

extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourH1=clrPaleGoldenrod;
extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourH4=clrBurlyWood;
extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourD1=clrSaddleBrown;
extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourW1=clrLawnGreen;
extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourH1=clrGreen;

Your code does not compile! Always reference the documentation when in doubt. And please paste code properly with the "</>" icon or Alt-S.

Here is an example of what it seems you are looking for (the code smaple is valid for both MQL4 and MQL5) ...

input color ColourH1 = clrPaleGoldenrod;
input color ColourH4 = clrBurlyWood;
input color ColourD1 = clrSaddleBrown;

void SomeFunction( void ) {
   if( !ObjectSetInteger( 0, "H1ObjectName", OBJPROP_COLOR, ColourH1 ) ) { Print( "Unable to set colour of H1 object" ); };
   if( !ObjectSetInteger( 0, "H4ObjectName", OBJPROP_COLOR, ColourH4 ) ) { Print( "Unable to set colour of H4 object" ); };
   if( !ObjectSetInteger( 0, "D1ObjectName", OBJPROP_COLOR, ColourD1 ) ) { Print( "Unable to set colour of D1 object" ); };
};
 
Thank you for your help, gentlemen!
 
Buckets #: Thank you for your help, gentlemen!
For my part, you are welcome!
 
Buckets #: I also do not understand the comments "Always reference the documentation when in doubt. And please paste code properly with the "</>" icon or Alt-S.". Could you please clarify that for idiots like me?  Thanks.

How to post code ...


 
Buckets #: What is the MQL4 command to place a label at the level of a horizontal line. For example, a horizontal line is at a calculated value and I would like to label it with its properties, at the price level on the left hand side of the chart.  I have the label set up, printing and ready on the X axis but I can't work out how to define the label Y axis to the value of the horizontal line. 

It depends. If you want it on the Left hand side, then simply give the horizontal line a description and it will apear there.

On the right hand side however, it is not that easy. You have to place either a text object or a object label object depending on what you want to achieve.

If you want it always visible as you scroll the chart then a Label object will be best, but you will have to compensate for vertical shift of the chart.

If you only want it visible on the current most recent bar, then you can use a Text object, but you will have to update its position on every new bar.

 
Buckets #:

Note for Fernando Carreiro and William Roeder - Thanks for your comments re my previous.  I posted that non-compilable piece of code because I was requested to do so by Keith Watford, who I understand is a moderator. 

I requested that you post your code, I didn't ask for you to post code that will not compile. You had not mentioned anything about getting compilation errors.

 

Is there a step by step guide for setting up a Signal Follow purchase?  I've got to say there is very little current info or videos that is readily available to guide that journey.  The one "detailed" video for starting the subscription is a link to a 6-yr old Youtube video.  Very disappointing.

TCB

 

All sorted thanks to the references.  Used text not label.