i can not able to ObjectCreate in indicator_separate_window

 

i can not able to create OBJ_ARROW in  indicator_separate_window. But i can able to create OBJ_LABEL. please help me to fix the problem. I found reason for that.

OBJ_ARROW still at Time 1970.01.01 00:00 and Value: 0. it not taken OBJPROP_XDISTANCE and OBJPROP_YDISTANCE.

my codes is:


#property copyright "Copyright 2018"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
string indicator_Name="Sample";
int window;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
  IndicatorShortName(indicator_Name);
   window= WindowFind(indicator_Name);
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   if(window<0)
               {
                  // if the number is -1, there is an error
                  Print("Can\'t find window");
                  return(0);
               }
  
   //Object arrow 
   ObjectCreate(0,"line",OBJ_ARROW,window,0,0);
   ObjectSet("line",OBJPROP_ARROWCODE,10);            
   ObjectSet("line",OBJPROP_COLOR,GreenYellow);
   ObjectSet("line",OBJPROP_WIDTH,3);
   ObjectSet("line",OBJPROP_XDISTANCE,400);
   ObjectSet("line",OBJPROP_YDISTANCE,125);
   ObjectSet("line",OBJPROP_CORNER,CORNER_LEFT_UPPER);
   WindowRedraw();   
   
   
   //Object label
   string sObjName="xxx_";
               ObjectCreate(sObjName, OBJ_LABEL, window, 0, 0);
               ObjectSetText(sObjName,"***", 15,NULL, Lime);
               ObjectSet(sObjName,OBJPROP_XDISTANCE,380);
               ObjectSet(sObjName,OBJPROP_YDISTANCE,125);
               ObjectSet(sObjName,OBJPROP_CORNER,CORNER_LEFT_UPPER);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+


i hope something to do for that line. Time and price. So how to fix it?

Actually i need XDISTANCE and YDISTANCE for my Arrow.

Thank you.

ObjectCreate(0,"line",OBJ_ARROW,window,0,0)
 

you can see it now!

 
Thushara Dissanayake:

i can not able to create OBJ_ARROW in  indicator_separate_window. But i can able to create OBJ_LABEL. please help me to fix the problem. I found reason for that.

OBJ_ARROW still at Time 1970.01.01 00:00 and Value: 0. it not taken OBJPROP_XDISTANCE and OBJPROP_YDISTANCE.

Actually i need XDISTANCE and YDISTANCE for my Arrow.

OBJ_ARROW is bound to the time and price (indicator value) coordinates. You can't set XDISTANCE and YDISTANCE for arrows.