I'm tired of trying to draw arrows in my sub window. Help me with this :-(

 

I tried bellow code, nothing is happening. When I check object list, arrow object has created but it's not visible anyway in the sub window no matter how.

the object's time coordinates are always showing as 1970.01.01 not matter how I try to set it to the current date time.


the arrows I'm trying to draw only based on coordinates. not need indicator data for them.

All I want is to draw arrows and fix them at a left side of the sub window so arrows will not move with the chart when chart is dragging left to right / right to left. I'm attaching a sample code bellow. Rest of the my indicator is fine, all I need is to fix this arrow drawing part.

//+------------------------------------------------------------------+
//|                                                       Arrows.mq5 |
//|                                          Copyright, H A T LAKMAL |
//|                                           https://t.me/Lakmal846 |
//+------------------------------------------------------------------+
#property copyright "Copyright, H A T LAKMAL"
#property link      "https://t.me/Lakmal846"
#property version   "1.00"
#property indicator_separate_window

#property indicator_buffers 1
#property indicator_plots 1
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

   int ChartHeight = 150;
   string ShortName = "Multi Timefame Analyzer" + TimeToString(TimeCurrent(),TIME_DATE);
   IndicatorSetString(INDICATOR_SHORTNAME,ShortName);
   IndicatorSetInteger(INDICATOR_HEIGHT,ChartHeight);




  // Draw test arrow
   double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);

   ObjectCreate(0,"01Min_Arrow",OBJ_ARROW,1,0,0);
   ObjectGetInteger(0,"01Min_Arrow",OBJPROP_ARROWCODE,233);
   
   ObjectSetInteger(0,"01Min_Arrow",OBJPROP_COLOR,clrLimeGreen);
   
   ObjectSetInteger(0,"01Min_Arrow", OBJPROP_CORNER, CORNER_LEFT_LOWER);
   ObjectSetInteger(0,"01Min_Arrow", OBJPROP_XDISTANCE, 10);
   ObjectSetInteger(0,"01Min_Arrow", OBJPROP_YDISTANCE, ChartHeight - 10);

   



//---
   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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Hapu Arachchilage Tharindu Lakmal:

I tried bellow code, nothing is happening. When I check object list, arrow object has created but it's not visible anyway in the sub window no matter how.

the object's time coordinates are always showing as 1970.01.01 not matter how I try to set it to the current date time.


the arrows I'm trying to draw only based on coordinates. not need indicator data for them.

All I want is to draw arrows and fix them at a left side of the sub window so arrows will not move with the chart when chart is dragging left to right / right to left. I'm attaching a sample code bellow. Rest of the my indicator is fine, all I need is to fix this arrow drawing part.

I don't believe that you can select a chart window for objects by specifying the window property of an indicator.

Have a look at  ChartWindowFind - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5 in order to select the subwindow for objects.

Documentation on MQL5: Chart Operations / ChartWindowFind
Documentation on MQL5: Chart Operations / ChartWindowFind
  • www.mql5.com
The function returns the number of a subwindow where an indicator is drawn. There are 2 variants of the function. 1. The function searches in the...
 

You need to specify a time for the subwindow where it will be seen for example time[rates_total-1] , or time[i] if you use the object in a loop

 
Hapu Arachchilage Tharindu Lakmal:

I tried bellow code, nothing is happening. When I check object list, arrow object has created but it's not visible anyway in the sub window no matter how.

the object's time coordinates are always showing as 1970.01.01 not matter how I try to set it to the current date time.


the arrows I'm trying to draw only based on coordinates. not need indicator data for them.

All I want is to draw arrows and fix them at a left side of the sub window so arrows will not move with the chart when chart is dragging left to right / right to left. I'm attaching a sample code bellow. Rest of the my indicator is fine, all I need is to fix this arrow drawing part.

Arrows are on the price time chart not on the foreground.

Use a label object , set it's font to wingdings and set it's objprop_text to the arrow you want.

You can find the arrow by opening the character map from windows accessories 

 
Lorentzos Roussos #:

Arrows are on the price time chart not on the foreground.

Use a label object , set it's font to wingdings and set it's objprop_text to the arrow you want.

You can find the arrow by opening the character map from windows accessories 

This method works. thanks for the reply.

 
Conor Mcnamara #:

You need to specify a time for the subwindow where it will be seen for example time[rates_total-1] , or time[i] if you use the object in a loop

Using labels is the option.