Draw Short Line IN Candle

 

Hello,

i´m new in MQL5 and i have a problem with draw short horizontal lines in candles.

I had tested and i can draw line between candles using Trend Lines, without Ray. But i want draw a short horizontal line in candle not between. Is possible in MT5?

Short Horizontal Line

 

Thanks for help.

 

Yes it's possible but you have to use "Precise time scale"

  • Precise time scale — if this option is disabled, objects are bound to bars along the horizontal scale of a chart. If you enable it, then it is possible to position an object at any point between bars.
Platform Settings - Getting Started - MetaTrader 5
Platform Settings - Getting Started - MetaTrader 5
  • www.metatrader5.com
The trading platform provides multiple settings to help you conveniently customize it. Click " Options" in the Tools menu or press "Ctrl+O". Charts — common settings of price charts and parameters of objects management: object selection straight after creation, immediate object configuration, and docking parameters; Trade — default parameters...
 
Thanks Alain for your reply. 
But I think that is possible without Precise time scale. 

I saw a indicator that make  shorts horizontal lines and shorts vertical lines (like a stair) above or below the candles. 

It's a Hilo Indicator in forms of stair. 
 
Alexandre Nakamura:
Thanks Alain for your reply. 

But I think that is possible without Precise time scale. 


No it's not possible with timed objects (Trend lines).
I saw a indicator that make  shorts horizontal lines and shorts vertical lines (like a stair) above or below the candles. 

It's a Hilo Indicator in forms of stair. 
Can be using canvas, but your question was about trend lines.
 
Alain Verleyen:

Yes it's possible but you have to use "Precise time scale"

Thanks for pointing this out, @Alain. I had been using a horizontal line from the time before the bar to the time after the bar.

 
Sorry. My English is not good. I want say that I tried do it with Trend Lines.
But I am trying do it in an indicator using something that work. 
Is it possible with Canvas? 
I will see it. 

Very thanks for your help. 
 
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   1
//--- plot Median
#property indicator_label1  "Median"
#property indicator_type1   DRAW_COLOR_HISTOGRAM2
#property indicator_color1  clrRoyalBlue,clrFireBrick
#property indicator_style1  STYLE_SOLID
#property indicator_width1  5
//--- indicator buffers
double Buffer1[];
double Buffer2[];
double Colors[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Buffer1,INDICATOR_DATA);
   SetIndexBuffer(1,Buffer2,INDICATOR_DATA);
   SetIndexBuffer(2,Colors,INDICATOR_COLOR_INDEX);
//---
   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[])
  {
//---
   int begin=rates_total!=prev_calculated?prev_calculated:rates_total-1;
   
   for(int i=begin;i<rates_total;i++)
     {
      Buffer1[i]=(open[i]+close[i])/2;
      Buffer2[i]=Buffer1[i]-1*_Point*10;
      Colors[i]=close[i]>=open[i]?0:1;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Ernst Van Der Merwe:
Doesn't really met the requirement.
 

Very Thanks for help.

I will try do it with Canvas.