I want to draw rectangles on top of wicks - trying to use OBJ_RECTANGLE

To add comments, please log in or register
tenakha
21
tenakha  

Hi,

I want to superimpose a rectangle on top of wicks. I'm trying to use ObjectCreate(OBJ_RECTANGLE).

But the rectangle that gets drawn is not 'ON' the wick - its to the left (or right).

I am using Time[0] and Time[1] to give the x coordinates of the rectangle. And the prices for the y coords.

The y coords is fine.

I can't adjust the x positions by adding/subtracting time units from the time.

How can I best do this? Am I going about this the wrong way perhaps?

Tenakha.


Code:

      if (close > open){
         Print("Time[0]: " + string(Time[0]));
         datetime time1 = Time[0];
         datetime time2 = Time[1];
         //time1 = time1 - (60*10);
         time2 = time2 - (60);
         Print("Time1: " + string(time1));
         
         ObjectCreate("BullUp"+string(rectangle), OBJ_RECTANGLE, 0, time1, close, time2, high);
         ObjectCreate("BullDown"+string(rectangle), OBJ_RECTANGLE, 0, time1, open, time2, low);
         rectangle++;
      }
William Roeder
20210
William Roeder  
In MT4 you can only draw from center of one candle to center of another. Subtracting 60 will not work.
tenakha
21
tenakha  

Thank you William - won't waste more time on it.

I wonder if i need to write a custom indicator.


William Roeder:
In MT4 you can only draw from center of one candle to center of another. Subtracting 60 will not work.
Anthony Garot
3264
Anthony Garot  
tenakha:

Thank you William - won't waste more time on it.

I wonder if i need to write a custom indicator.


Maybe a custom indicator using:

DRAW_COLOR_CANDLES

Multicolored candlesticks

I'm not 100% sure this is available in MT4, but this page mentions it:
https://docs.mql4.com/constants/indicatorconstants

So, you simply make the new candles extend from the high to the low. That could be the rectangles you seek.

To add comments, please log in or register