# Tos indicator to javascript

**URL:** <https://community.tradovate.com/t/tos-indicator-to-javascript/4509>\
**Category:** Custom Indicators\
**Created:** [April 23, 2022, 6:20pm UTC](https://community.tradovate.com/t/tos-indicator-to-javascript/4509 "2022-04-23T18:20:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JEREMIAH\_SHEBAYAN](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@JEREMIAH\_SHEBAYAN](https://community.tradovate.com/u/JEREMIAH_SHEBAYAN)\
**Post date:** [April 23, 2022, 6:20pm UTC](https://community.tradovate.com/t/tos-indicator-to-javascript/4509/1 "2022-04-23T18:20:21Z")

</div>

Hi need help porting this tos indicator to tradovate. It plots previous day high, low, premarket high, low, and mid

#Plot yesterday’s high / low  
input Showchartbubbles = yes;  
input ShowTodayOnly = yes;  
def Today = if GetDay() == GetLastDay() then 1 else 0;  
plot Yhigh = if ShowTodayOnly and !Today then Double.NaN else high(period = “day” )[1];  
plot Ylow = if ShowTodayOnly and !Today then Double.NaN else low(period = “day” )[1];

Yhigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);  
Yhigh.SetDefaultColor(Color.UPTICK);  
Yhigh.SetLineWeight(2);  
Ylow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);  
Ylow.SetDefaultColor(Color.DOWNTICK);  
Ylow.SetLineWeight(2);

# 

# 

declare once\_per\_bar;

input PlotPreMktLinesHrsPastOpen = yes;  
def bar = BarNumber();

def nan = Double.NaN;  
def vHigh = high;  
def vLow = low;

def PMhrs = RegularTradingStart (GetYYYYMMDD()) \> GetTime();  
def RMhrs = RegularTradingStart (GetYYYYMMDD()) \< GetTime();  
def PMStart = RMhrs[1] and PMhrs;  
def PMHigh = CompoundValue(1, if PMStart then vHigh else if PMhrs then Max(vHigh, PMHigh[1]) else PMHigh[1], 0);  
def PMLow = CompoundValue(1, if PMStart then vLow else if PMhrs then Min(vLow, PMLow[1]) else PMLow[1], 0);  
def highBar = if PMhrs and vHigh == PMHigh then bar else nan;  
def lowBar = if PMhrs and vLow == PMLow then bar else nan;  
def PMHighBar = if bar == HighestAll(highBar) then PMHigh else PMHighBar[1];  
def PMLowBar = if bar == HighestAll(lowBar) then PMLow else PMLowBar[1];

plot PMH = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0  
then PMHighBar  
else nan;  
plot PML = if PlotPreMktLinesHrsPastOpen and PMLowBar != 0  
then PMLowBar  
else nan;  
plot PMMid = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0 and PMLowBar != 0  
then (PMHighBar + PMLowBar) / 2  
else nan;

AddChartBubble(ShowChartBubbles and bar == HighestAll(highBar),  
PMHigh,  
“PM High”,  
Color.Gray,  
1);

AddChartBubble(ShowChartBubbles and bar == HighestAll(lowBar),  
PMLow,  
“PM Low”,  
Color.Gray,  
0);

AddChartBubble(ShowChartBubbles and bar == Max(HighestAll(highBar), HighestAll(lowBar)),  
(PMHighBar + PMLowBar) / 2,  
“PM Mid”,  
Color.Gray,  
1);

addcloud(pmh, yhigh,Color.light\_gray, Color.Light\_gray);  
AddCloud(pml, ylow, Color.light\_gray, Color.Light\_gray);
