Sample
void SetArrow(datetime ArrowTime, double Price, double ArrowCode, color ArrowColor) { int i,err; string obj_name; //string ArrowName = indicator_name+DoubleToStr(ArrowTime,0); string ArrowName = indicator_name+DoubleToStr(ArrowCode,0); //if (ObjectFind(ArrowName) != -1) ObjectDelete(ArrowName); //--- for (i=ObjectsTotal()-1;i>=0;i--) { obj_name=ObjectName(i); if (indicator_name==StringSubstr(obj_name,0,StringLen(indicator_name))) ObjectDelete(obj_name); } //--- if (indicator_name==StringSubstr(ArrowName,0,StringLen(indicator_name))) ObjectDelete(ArrowName); if(!ObjectCreate(ArrowName, OBJ_ARROW, 0, ArrowTime, Price)) { err=GetLastError(); Print("error: can't create Arrow! code #",err); return; } else { ObjectSet(ArrowName, OBJPROP_ARROWCODE, ArrowCode); ObjectSet(ArrowName, OBJPROP_COLOR , ArrowColor); WindowRedraw(); } }
Rosh:
Sample
Sample
void SetArrow(datetime ArrowTime, double Price, double ArrowCode, color ArrowColor) { int i,err; string obj_name; //string ArrowName = indicator_name+DoubleToStr(ArrowTime,0); string ArrowName = indicator_name+DoubleToStr(ArrowCode,0); //if (ObjectFind(ArrowName) != -1) ObjectDelete(ArrowName); //--- for (i=ObjectsTotal()-1;i>=0;i--) { obj_name=ObjectName(i); if (indicator_name==StringSubstr(obj_name,0,StringLen(indicator_name))) ObjectDelete(obj_name); } //--- if (indicator_name==StringSubstr(ArrowName,0,StringLen(indicator_name))) ObjectDelete(ArrowName); if(!ObjectCreate(ArrowName, OBJ_ARROW, 0, ArrowTime, Price)) { err=GetLastError(); Print("error: can't create Arrow! code #",err); return; } else { ObjectSet(ArrowName, OBJPROP_ARROWCODE, ArrowCode); ObjectSet(ArrowName, OBJPROP_COLOR , ArrowColor); WindowRedraw(); } }
thanks for the reply,
I have try using color as a parametertype and success to pass the Green color integer, but how about the parameter is somting like C'236,130,0' to pass the function ?
for example :
CreateObject("Test2",C'236,130,0') // --- please check, as is the sperate of the parameter.
void CreateObject(string Name1,color DefineColor)
{
ObjectCreate(Name1,OBJ_LABLEL,WindowFind("Indicato r1"),0,0);
ObjectSetText(Name1,"Testing",12,"Arial Bold:,DefineColor);
}
where define parameter like C'236,130,0' is posible to pass in the function ?
rgds bob
Hi Phy
Thanks for your reply
from your reply I got my answer, convert into integer first, and then send by integer, my previous question : I don't know the relation between color type variable with the integer so I cannot send directly like :
CreateObject("Test2",C'236,130,0'), because the comma act as like the parameter seperator, after your explation by example, so I get the idea, convert first into integer, and then send as a color parameter, thanks explanation by simple example.
rgds bob
Thanks for your reply
from your reply I got my answer, convert into integer first, and then send by integer, my previous question : I don't know the relation between color type variable with the integer so I cannot send directly like :
CreateObject("Test2",C'236,130,0'), because the comma act as like the parameter seperator, after your explation by example, so I get the idea, convert first into integer, and then send as a color parameter, thanks explanation by simple example.
rgds bob
I don't see a problem:
int start() { SetColor( C'127,128,128'); return(0); } void SetColor( color myColor){ ObjectCreate("RECT", OBJ_RECTANGLE, 0, Time[0], Close[0], Time[50], Close[50]); ObjectSet("RECT", OBJPROP_COLOR, myColor); }
Hi:
I don't see a problem:
int start() { SetColor( C'127,128,128'); return(0); } void SetColor( color myColor){ ObjectCreate("RECT", OBJ_RECTANGLE, 0, Time[0], Close[0], Time[50], Close[50]); ObjectSet("RECT", OBJPROP_COLOR, myColor); }
See also https://forum.mql4.com/9407
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all
I have a problem :how to pass the parameter to user difine function :
example :
CreateObject("Test1",Green);
CreateObject("Test2",C'236,130,0')
CreateObject("Test3",32768 )
void CreateObject(string Name1,int DefineColor)
{
ObjectCreate(Name1,OBJ_LABLEL,WindowFind("Indicato r1"),0,0);
ObjectSetText(Name1,"Testing",12,"Arial Bold:,DefineColor);
}
1. so how to pass the Color for Green, C'235,130,0,' or 32768 ?
2. in the User define function, what is the type of the color? can be string ? int? double or color ? I have try but failed
3. what is the type variable for color, or can be convert from interger, string into color type variable ?
4. can you all show me the url for this kind of detail description.
thanks for the help
rgds bob