text with ObjectCreate

 
Hello,

I try to draw the Differenze between Ask and MA in Pips as text with ObjectCreate, but it doesn't work. where is mistake.

Thank you


Source Code:


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

   ObjectCreate("Diff",OBJ_LABEL,0,0,0,0,0);  // Creating obj.
   ObjectSet("Diff", OBJPROP_XDISTANCE,scaleX+offsetX);// X coordinate
   ObjectSet("Diff", OBJPROP_YDISTANCE,scaleY+offsetY);// Y coordinate       
   ObjectSetText("Diff",0,fontSize,"Arial",White);     

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
      ObjectDelete("Diff");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int    counted_bars = IndicatorCounted();
   digits = MarketInfo(Symbol(),MODE_DIGITS);
//----
   POS = Bars - counted_bars;
   
      MA = iMA(Symbol(),0, MA_Period, 0, ma_method, applied_price, 0); 

      difference = Ask - MA;
      
      if (difference >= 0){
         ObjectSetText("Diff",difference,fontSize,"Wingdings",Lime);
      }
      else{
       
         ObjectSetText("Diff",difference,fontSize,"Arial",Red); 
      }
  
   return(0);
  }
 
sam09:
Hello,

I try to draw the Differenze between Ask and MA in Pips as text with ObjectCreate, but it doesn't work. where is mistake.

Thank you


Source Code:


Try it out (I didnt do that):

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

   ObjectCreate("Diff",OBJ_LABEL,0,0,0,0,0);  // Creating obj.
   ObjectSet("Diff", OBJPROP_XDISTANCE,scaleX+offsetX);// X coordinate
   ObjectSet("Diff", OBJPROP_YDISTANCE,scaleY+offsetY);// Y coordinate       
   ObjectSetText("Diff","0",fontSize,"Arial",White);     

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
      ObjectDelete("Diff");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
      
  digits = MarketInfo(Symbol(),MODE_DIGITS);

      MA = iMA(Symbol(),0, MA_Period, 0, ma_method, applied_price, 0); 

      difference = Ask - MA;
      
      if (difference >= 0){
         ObjectSetText("Diff",DoubleToStr(difference, digits),fontSize,"Arial",Lime);
      }
      else{
       
         ObjectSetText("Diff",DoubleToStr(difference, digits),fontSize,"Arial",Red); 
      }
  
   return(0);
  }
Cheers
 
ggekko:

Try it out (I didnt do that):

Cheers







Thank you very much .. it works.

Reason: