Is this possible?

 

I'm trying to code an indicator that can change the colour of a particular candlestick (e/g candle stick at position 0 = current candle) ONLY.

I tried using the chartsetinterger function but it changed the color of all the candlesticks in the charts (There is no option to specify the exact candle you want to change the colour or maybe I am missing something)

I looked here in the forum for more ideas and I found on where I can use a rectangle over the candle. Okay? That didn't turn out so well. Since I used time for the rectangle co-ordinates as time[0] and time[1] respectively.

Here, I'll show you the codes. If you can help, Please do. Thank you 

void Drawrectangle(double price1, double price2, const datetime time1, const datetime time2, const string text)
{
  
    string name = ArrowPrefix + "Arrow" + TimeToString(time1);
    if (ObjectFind(ChartID(), name) > -1) return;

    ObjectCreate(ChartID(), name, OBJ_RECTANGLE, 0, time1,price1,time2,price2);
    ObjectSetInteger(0, name, OBJPROP_COLOR, inp_colour);
    ObjectSetInteger(0, name, OBJPROP_SELECTABLE, false);
    ObjectSetInteger(0, name, OBJPROP_FILL,true);
}

void OnCalculate 
{ // condition met so draw rectangle

     //draw rectangle

   Drawrectangle(close[i],open[i],time[i],time[i+1],"  ");
    
}
 
Chioma Obunadike:

I'm trying to code an indicator that can change the colour of a particular candlestick (e/g candle stick at position 0 = current candle) ONLY.

I tried using the chartsetinterger function but it changed the color of all the candlesticks in the charts (There is no option to specify the exact candle you want to change the colour or maybe I am missing something)

I looked here in the forum for more ideas and I found on where I can use a rectangle over the candle. Okay? That didn't turn out so well. Since I used time for the rectangle co-ordinates as time[0] and time[1] respectively.

Here, I'll show you the codes. If you can help, Please do. Thank you 




 ObjectCreate(ChartID(), name, OBJ_RECTANGLE, 0, time1 - (PeriodSeconds()/2),price1,time1 + (PeriodSeconds()/2),price2);
 
Dominik Christian Egert #:



doesn't solve the problem but thanks for trying

 
Chioma Obunadike #:

doesn't solve the problem but thanks for trying

Try setting Terminal -> Options -> Chart -> "Precise time scale" and see if it works.


 
Dominik Christian Egert #:
Try setting Terminal -> Options -> Chart -> "Precise time scale" and see if it works.

I'm sorry. I can't find any settings like you described

 
Okay got it. Perfect. It works now. Thank you so much