Download MetaTrader 5

Anyone able to give me some help on this

To add comments, please log in or register
Thehallster
106
Thehallster  

Hi All,

I think I have a drawing problem with my indicator. Works perfectly on my MT4 but doesnt on other peoples. cant suss it out any tips?

 

 Stochastic missing text

 

Where as on other peoples it does this without the labels:

without labels 

 

My Code Draws these labels using this code: and the Show Stochlabels is fixed to True in the variables so its not user input errors thought it was so locked it and still got the same problem. Thinking it could be by using the WindowFind but i didnt want to use Window Index incase someone wants to use it with other indicators it will mess it up otherwise

  if(Show_StochLabels==true)
     {
      ObjectCreate("stoLABEL", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL","STOCH #1 :   "+STF1+"", 9, "Tahoma Narrow", indicator_color1);
      ObjectSet("stoLABEL", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL", OBJPROP_YDISTANCE, 5);
//----
      ObjectCreate("stoLABEL1", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL1","STOCH #2 :   "+STF2+"", 9, "Tahoma Narrow", indicator_color3);
      ObjectSet("stoLABEL1", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL1", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL1", OBJPROP_YDISTANCE, 20);
//----
      ObjectCreate("stoLABEL2", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL2","STOCH #3 :   "+STF3+"", 9, "Tahoma Narrow", indicator_color5);
      ObjectSet("stoLABEL2", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL2", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL2", OBJPROP_YDISTANCE, 35);
//----
      ObjectCreate("stoLABEL4", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL4","STOCH #4 :   "+STF4+"", 9, "Tahoma Narrow", indicator_color7);
      ObjectSet("stoLABEL4", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL4", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL4", OBJPROP_YDISTANCE, 50);
//----
      ObjectCreate("stoLABEL5", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL5","STOCH #5 :   "+STF5+"", 9, "Tahoma Narrow", indicator_color9);
      ObjectSet("stoLABEL5", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL5", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL5", OBJPROP_YDISTANCE, 65);
     }


 

honest_knave
Moderator
2342
honest_knave  
ObjectSet("stoLABEL4", OBJPROP_XDISTANCE, 1165+Shift_Text);

Possibly off the edge of their screen (to the right).

You would be better to anchor it to the other side (OBJPROP_ANCHOR)

If they open the Object List can they see the objects listed?
nicholishen
1537
nicholishen  

You might just need to use ChartSetInteger to set chart objects to show. Here's a script to toggle it on and off to see if you can replicate the objects not shoeing on the screen. 

 

//+------------------------------------------------------------------+
//|                                   ChartObjDescriptionsON_OFF.mq5 |
//|                                                      nicholishen |
//|                                   www.reddit.com/u/nicholishenFX |
//+------------------------------------------------------------------+
#property copyright "nicholishen"
#property link      "www.reddit.com/u/nicholishenFX"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   long value;
  
   ResetLastError();
//--- receive the property value
   if(!ChartGetInteger(ChartID(),CHART_SHOW_OBJECT_DESCR,0,value)) {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return;
   } else {
      Print("Chart was displaying Objects = ",valueToString(value));
   }

   value = value == true ? value = false : value = true;

   if(!ChartSetInteger(ChartID(),CHART_SHOW_OBJECT_DESCR,0,value)) {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return;
   } else {
      Print("Chart is now displaying Objects = ",valueToString(value));
   }
}
//+------------------------------------------------------------------+

string valueToString(const long value){
   if(value == true)return "TRUE";
   else if( value == false)return "FALSE";
   else return "ERROR";
}
honest_knave
Moderator
2342
honest_knave  
nicholishen:

You might just need to use ChartSetInteger to set chart objects to show. Here's a script to toggle it on and off to see if you can replicate the objects not shoeing on the screen. 

Your code is doing something a little different.

CHART_SHOW_OBJECT_DESCR controls whether the description of an object is visible, not the object itself.

It is controlling this:

 

 

Example:

ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,true); 

 

ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,false); 

 

______ 

By the way, you can simplify this:

value = value == true ? value = false : value = true;

 To this:

value = !value;


 

nicholishen
1537
nicholishen  

value = !value;


 

Nice. 
Thehallster
106
Thehallster  

Hey Knave thanks for that advice, seems to be the issue. I've tried editing it to put it over the other side but any idea how to get my Rectangle shape to draw. Never done this before but trying to get it to format right and doesnt seem to want to fill with colours? ive tried it a few ways and cant seem to get the knack of this. like i said never done this before Ive tried making it as a label but didnt like that didnt seem to want to follow the colours i set.

 no shapes

if(Show_StochLabels==true)
     {
      ObjectCreate("StoRectangle",OBJ_RECTANGLE,WindowFind("BigBroking MTF STOCH #1 "),10,15,10,100);
      //--- set the chart's corner, relative to which point coordinates are defined
      ObjectSet("StoRectangle",OBJPROP_CORNER,CORNER_LEFT_UPPER);
      //--- set label coordinates
      ObjectSet("StoRectangle",OBJPROP_XDISTANCE,10);
      ObjectSet("StoRectangle",OBJPROP_YDISTANCE,10);
      //--- set label size
      ObjectSet("StoRectangle",OBJPROP_XSIZE,150);
      ObjectSet("StoRectangle",OBJPROP_YSIZE,100);
      //--- set background color
      ObjectSet("StoRectangle",OBJPROP_FILL,clrBlack);
      //--- set rectangle color
      ObjectSet("StoRectangle",OBJPROP_COLOR,clrBlack);
      //--- set border type
      ObjectSet("StoRectangle",OBJPROP_BORDER_TYPE,0);
      //--- set flat border color (in Flat mode)
      ObjectSet("StoRectangle",OBJPROP_COLOR,clrBlack);
      //--- set flat border line style
      ObjectSet("StoRectangle",OBJPROP_STYLE,1);
      //--- set flat border width
      ObjectSet("StoRectangle",OBJPROP_WIDTH,1);
      //--- display in the foreground (false) or background (true)
      //ObjectSet("StoRectangle",OBJPROP_BACK,false);

      //----
      ObjectCreate("stoLABEL",OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "),0,0);
      ObjectSetText("stoLABEL","STOCH #1 :   "+STF1+"",9,"Tahoma Narrow",indicator_color1);
      ObjectSet("stoLABEL",OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSet("stoLABEL",OBJPROP_XDISTANCE,20);
      ObjectSet("stoLABEL",OBJPROP_YDISTANCE,20);
      //----
      ObjectCreate("stoLABEL1",OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "),0,0);
      ObjectSetText("stoLABEL1","STOCH #2 :   "+STF2+"",9,"Tahoma Narrow",indicator_color3);
      ObjectSet("stoLABEL1",OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSet("stoLABEL1",OBJPROP_XDISTANCE,20);
      ObjectSet("stoLABEL1",OBJPROP_YDISTANCE,35);
      //----
      ObjectCreate("stoLABEL2",OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "),0,0);
      ObjectSetText("stoLABEL2","STOCH #3 :   "+STF3+"",9,"Tahoma Narrow",indicator_color5);
      ObjectSet("stoLABEL2",OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSet("stoLABEL2",OBJPROP_XDISTANCE,20);
      ObjectSet("stoLABEL2",OBJPROP_YDISTANCE,50);
      //----
      ObjectCreate("stoLABEL4",OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "),0,0);
      ObjectSetText("stoLABEL4","STOCH #4 :   "+STF4+"",9,"Tahoma Narrow",indicator_color7);
      ObjectSet("stoLABEL4",OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSet("stoLABEL4",OBJPROP_XDISTANCE,20);
      ObjectSet("stoLABEL4",OBJPROP_YDISTANCE,65);
      //----
      ObjectCreate("stoLABEL5",OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "),0,0);
      ObjectSetText("stoLABEL5","STOCH #5 :   "+STF5+"",9,"Tahoma Narrow",indicator_color9);
      ObjectSet("stoLABEL5",OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSet("stoLABEL5",OBJPROP_XDISTANCE,20);
      ObjectSet("stoLABEL5",OBJPROP_YDISTANCE,80);
     }
//----
   return(0);
Thehallster
106
Thehallster  

Waheyyy! Knave I actually fixed it on my own!!

 

Couldnt use the OBJ_rectangle by the looks of it due to it not being on the main chart using price and date etc.

 

Did it with OBJ-Rectangle-label

 

with background ]

 

if(Show_StochLabels==true)
     {
      ObjectCreate("StoRectangle",OBJ_RECTANGLE_LABEL,WindowFind("BigBroking MTF STOCH #1 "),OBJPROP_XDISTANCE,OBJPROP_XSIZE,OBJPROP_YDISTANCE,OBJPROP_YSIZE);
      //--- set the chart's corner, relative to which point coordinates are defined
      ObjectSet("StoRectangle",OBJPROP_CORNER,CORNER_LEFT_UPPER);
      //--- set label coordinates
      ObjectSet("StoRectangle",OBJPROP_XDISTANCE,15);
      ObjectSet("StoRectangle",OBJPROP_YDISTANCE,15);
      //--- set label size
      ObjectSet("StoRectangle",OBJPROP_XSIZE,150);
      ObjectSet("StoRectangle",OBJPROP_YSIZE,95);
      //--- set background color
      ObjectSet("StoRectangle",OBJPROP_FILL,clrBlack);
      //--- set rectangle color
      ObjectSet("StoRectangle",OBJPROP_BGCOLOR,clrBlack);
      //--- set border type
      ObjectSet("StoRectangle",OBJPROP_BORDER_TYPE,2);
      //--- set flat border color (in Flat mode)
      ObjectSet("StoRectangle",OBJPROP_COLOR,clrBlack);
      //--- set flat border line style
      ObjectSet("StoRectangle",OBJPROP_STYLE,1);
      //--- set flat border width
      ObjectSet("StoRectangle",OBJPROP_WIDTH,5);
      //--- display in the foreground (false) or background (true)
      ObjectSet("StoRectangle",OBJPROP_BACK,false);


 

honest_knave
Moderator
2342
honest_knave  
Thehallster:

Waheyyy! Knave I actually fixed it on my own!!


To add comments, please log in or register