Color direction for an inside and outside bars


Category:
0
0

Hi Pete,

I am looking to plot inside and outside candles (IB/OB) on TOS charts.

I am looking to have the IB/OB to change color based upon the relationship of the open to the closing price.

For example; an inside bar (IB) is white if the close was greater than the open and black if the open is greater than the close.  Same with the outside bar (OB).

Thank you.

Marked as spam
Posted by (Questions: 5, Answers: 8)
Asked on February 29, 2020 5:21 pm
236 views
0
Private answer

I think this should do it. I didn't test it out but wrote this up from memory. Let me know if any errors show up or it requires any modifications.

def insideBar = high < high[1] and low > low[1];
def outsideBar = high > high[1] and low < low[1]; def upBar = close > open;
AssignPriceColor(if (insideBar or outsideBar) and upBar then Color.WHITE else if (insideBar or outsideBar) and !upBar then Color.BLACK else Color.CURRENT);

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on February 29, 2020 7:31 pm
0
Hi Peter, Thinkscript says; Invalid statement: AssignPriceColor at 3:1 sorry.
( at February 29, 2020 7:53 pm)
0
That was a typo, sorry. Used the word 'than' when it should have been 'then'. I have corrected the code in my answer and no longer produces an error.
( at February 29, 2020 8:20 pm)
0
Thank you. I couldn't figure it out. I appreciate your assistance.
( at February 29, 2020 8:43 pm)