I need:
if PipValue<0 then Show PipValue color = Red,else color = InfoColor
What shall I do?
Don't create the object when it already exists or you will get and error and the object won't be created. Check if the object exists before you try and create it, if it already exists just change it . . .
color LabelColor; LabelColor = InfoColor; if (PipValue < 0) LabelColor = Red; { string Pip = "PIP"; string PipValue = DoubleToStr(pipVal, 0); if(ObjectFind(Pip) < 0) ObjectCreate(Pip, OBJ_LABEL, 0 , 0, 0); // check if Object exists ObjectSet(Pip, OBJPROP_CORNER, 1); ObjectSet(Pip, OBJPROP_XDISTANCE, 10); ObjectSet(Pip, OBJPROP_YDISTANCE, 24); ObjectSetText(Pip, "PiP Count: "+PipValue, 8, "Tahoma", LabelColor); }
Thanks a lot RaptorUK, you are so fast ;)
It works, but I just want to change PipValue color to Red, not all the object text.
Regards
Thanks a lot RaptorUK, you are so fast ;)
It works, but I just want to change PipValue color to Red, not all the object text.
You mean Pip Object?1
Is it Okay now?
string PPip = "PIP"; string PipValue = DoubleToStr(pipVal, 0); if(ObjectFind(PPip ) < 0) ObjectCreate(PPip , OBJ_LABEL, 0 , 0, 0); // check if Object exists ObjectSet(PPip , OBJPROP_CORNER, 1); ObjectSet(PPip , OBJPROP_XDISTANCE, 10); ObjectSet(PPip , OBJPROP_YDISTANCE, 24); ObjectSetText(PPip , "PiP Count: "+PipValue, 8, "Tahoma", LabelColor);
You mean Pip Object?1
Is it Okay now?
If you want the text "PiP Count" in one colour and the PipValue in a different colour then you need one label Object for the "PiP Count" text and a different label Object for the numerical PipValue
Checking if an Object exists before you try to create it applies to all Objects where you are modifying them . . .
Thanks again man, I did it and it works so good.
One more question please, When I remove the indicator from chart, the object is still on chart ! How can be remove as long as indicator was remove of chart!
The code shows position's profit, but when position is close, it's still shows the last profit! I want it to show "0" after close the position (or shows "text") . What should I do?
What should I do?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I need:
if PipValue<0 then Show PipValue color = Red,else color = InfoColor
What shall I do?