bri8htf1y
New member
Hi all,
I often trade with price as percentage and need my charts set with RTH open as 0%. It seems the only option is to select a bar with the nearest closing price and Set Bar To 0% - and this must be done every time the timeframe changes. Usually not a big deal, but can be distracting in fast markets. Sooo...
I'm trying to add a script that paints the most proximate bar a bright color ( the bar that closes nearest to the RTH open price ). But for this method to work, the "zero bar" obviously can't be the RTH open bar , and it should select from all bars with a close on the chart including premarket bars.
Any help would be greatly appreciated!
Here's where I am:
input ShowZeroBars = yes;
def NA = Double.NaN;
def Bar = Barnumber();
def Today = GetLastDay() == GetDay();
def RTHOpen = if SecondsTillTime(0930) == 0 then open else RTHOpen[1];
def RTHO = RTHOpen;
def AllDay = Today && SecondsFromTime(0400) >= 0 && SecondsTillTime(1600) > 0;
def DayBar = if AllDay && !IsNaN(close) then Bar else NA;
def Proximity = if DayBar then AbsValue(close - RTHO) else Proximity[1];
def Proximate = LowestAll(Proximity);
def ProxBar = if Proximate == Proximity then Bar else NA;
def ZeroBar = close == RTHO;
AssignPriceColor(if ShowZeroBars && ProxBar then Color.CYAN else if close > open then Color.UPTICK else Color.DOWNTICK);
I often trade with price as percentage and need my charts set with RTH open as 0%. It seems the only option is to select a bar with the nearest closing price and Set Bar To 0% - and this must be done every time the timeframe changes. Usually not a big deal, but can be distracting in fast markets. Sooo...
I'm trying to add a script that paints the most proximate bar a bright color ( the bar that closes nearest to the RTH open price ). But for this method to work, the "zero bar" obviously can't be the RTH open bar , and it should select from all bars with a close on the chart including premarket bars.
Any help would be greatly appreciated!
Here's where I am:
input ShowZeroBars = yes;
def NA = Double.NaN;
def Bar = Barnumber();
def Today = GetLastDay() == GetDay();
def RTHOpen = if SecondsTillTime(0930) == 0 then open else RTHOpen[1];
def RTHO = RTHOpen;
def AllDay = Today && SecondsFromTime(0400) >= 0 && SecondsTillTime(1600) > 0;
def DayBar = if AllDay && !IsNaN(close) then Bar else NA;
def Proximity = if DayBar then AbsValue(close - RTHO) else Proximity[1];
def Proximate = LowestAll(Proximity);
def ProxBar = if Proximate == Proximity then Bar else NA;
def ZeroBar = close == RTHO;
AssignPriceColor(if ShowZeroBars && ProxBar then Color.CYAN else if close > open then Color.UPTICK else Color.DOWNTICK);