Highlight a candle by special date

Hi everyone,
I want to highlight a candle for a special date by changing the color or draw something on this candle. How can I do it?
Can anyone help me, pls?
Thanks

By using SetBarFillColor and/or PlotShapes or Gfx*.

dn = DateNum();// or use DateTime()

special_date = SelectedValue(dn);
date_cond = dn == special_date;

bull_bear_color = IIf(C>O, colorGreen, colorRed);
date_color = IIf(date_cond, colorYellow, bull_bear_color );

SetBarFillColor(date_color);

Plot( C, "Price", date_color, styleBar );
PlotShapes( date_cond * shapeSmallSquare, colorYellow, layer = 0, y = H, 12 );

using DateTime

dn = DateTime();//DateNum();

special_date = _DT("2019-03-20 00:00" );//SelectedValue(dn);
date_cond = dn == special_date;

bull_bear_color = IIf(C>O, colorGreen, colorRed);
date_color = IIf(date_cond, colorYellow, bull_bear_color );

SetBarFillColor(date_color);

Plot( C, "Price", date_color, styleBar );
PlotShapes( date_cond * shapeSmallSquare, colorYellow, layer = 0, y = H, 12 );

If daily bars are not created from intraday data but EOD data then in 2nd example use date without time.

special_date =_DT("2019-03-20" );
4 Likes

Thank you so much @fxshrat. I found the solution few hours ago but forgot to update my question :).
Btw, it is good for others who are facing this issue.
Thank you!.

@fxshrat Do you know how to create an array?
I have a file with multiple line, I want to read the data from this file and save it in an array (each line will be an element).
currently, I have to change the format, just one Line and separate by ";", then I read and using strExtract function but it is not really what I want to have.

If you already have single line separated by semicolon ( e.g. "1;2;3") then look here or here etc.
using MxFromString

file_data = /*Your file data line separated by semicolon*/;

line_formated = StrFormat( "[%s]", file_data );
mat = MxFromString(line_formated);

Otherwise if you want to have element by line then read here.
https://www.amibroker.com/kb/2015/09/26/how-to-populate-matrix-from-a-text-file/

For further Matrix functions scroll down to the bottom of this site
https://www.amibroker.com/guide/a_catfunref.html


On the other hand if you data has date and time information (in addition) then you may just use ASCII file import.
http://www.amibroker.com/guide/w_impwizard.html

And if you want to call that data from other symbols then take a look at foreign functions.
https://www.amibroker.com/guide/afl/foreign.html
https://www.amibroker.com/guide/afl/setforeign.html
https://www.amibroker.com/guide/afl/plotforeign.html


BTW, you don't need to say thank you every time. You may just as well say thanks by hitting heart button below of a post.

1 Like