Opening Price of any period

T

Trading51

Active member
2019 Donor
Opening Price of any period, 60, 120, 240 etc with a horizontal line with a small margin to the right of the chart, lets say a new hour started and you wanted the open of that bar, could some code this? thanks
 
T

Trading51

Active member
2019 Donor
Can someone help me with this, it seems quite simple but when you have zero programming skills its difficult
 
korygill

korygill

Active member
VIP
try this and if it's not want you want, draw a picture of what you want or describe it in greater detail. i am not 100% this is what you are looking for.
https://tos.mx/qmFCgel

Code:
input agg = AggregationPeriod.TWO_HOURS;
def data = close(period = agg);
plot AggClose = if !IsNaN(data) then data else data[1];
 
korygill

korygill

Active member
VIP
Update: use this link for Open, i mistakenly used close
https://tos.mx/NRifurx
Code:
input agg = AggregationPeriod.TWO_HOURS;
def data = open(period = agg);
plot AggClose = if !IsNaN(data) then data else data[1];

Screenshot I put on imgur
 
T

Trading51

Active member
2019 Donor
If I wanted to use 12 hour period how would I add that I noticed that TOS didn’t have this aggregation period, btw thanks for taking the time to do this
 
C

Citizen Quasar

New member
I am seeking to obtain the open/close/high/low of the very first bar and to use this value as the starting point for a horizontal line. Any help or advice will be greatly appreciated. :oops:
 
horserider

horserider

Well-known member
VIP
I am seeking to obtain the open/close/high/low of the very first bar and to use this value as the starting point for a horizontal line. Any help or advice will be greatly appreciated. :oops:
See if this fits what you want. Let us know how you are using it please.

Code:
# Draw horizontal line at market open price.
# Most code extracted from another study but forgot where.
# By Horserider.

input openingPMTime  = 0400.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input openingTime  = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.

def isDaily = If (GetAggregationPeriod() == AggregationPeriod.DAY, yes, no);

def isPreMarket = If (GetDay() == GetLastDay() and SecondsTillTime(openingPMTime) < 0, yes, no);
input LineWidth = 1;
def na = Double.NaN;

def isBelowDaily = If (GetAggregationPeriod() < AggregationPeriod.DAY, yes, no);
def isToday = If (GetDay() == GetLastDay() and SecondsFromTime(openingPMTime) >= 0, yes, no);
def day = GetDay();

def PMopenBar = day != day[1];
def PMOpen = if PMopenBar then open else PMOpen[1];

plot PlotPMOLine = if isToday and isBelowDaily then PMOpen else na;
     PlotPMOLine.SetDefaultColor(CreateColor(77, 166, 255));
     PlotPMOLine.SetLineWeight(LineWidth);
     PlotPMOLine.SetPaintingStrategy(PaintingStrategy.DASHES);
     PlotPMOLine.HideTitle();
     PlotPMOLine.HideBubble();
 
T

Trading51

Active member
2019 Donor
See if this fits what you want. Let us know how you are using it please.

Code:
# Draw horizontal line at market open price.
# Most code extracted from another study but forgot where.
# By Horserider.

input openingPMTime  = 0400.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.
input openingTime  = 0930.0; #hint OrMeanS: Begin Mean Period. Usually Market Open EST.

def isDaily = If (GetAggregationPeriod() == AggregationPeriod.DAY, yes, no);

def isPreMarket = If (GetDay() == GetLastDay() and SecondsTillTime(openingPMTime) < 0, yes, no);
input LineWidth = 1;
def na = Double.NaN;

def isBelowDaily = If (GetAggregationPeriod() < AggregationPeriod.DAY, yes, no);
def isToday = If (GetDay() == GetLastDay() and SecondsFromTime(openingPMTime) >= 0, yes, no);
def day = GetDay();

def PMopenBar = day != day[1];
def PMOpen = if PMopenBar then open else PMOpen[1];

plot PlotPMOLine = if isToday and isBelowDaily then PMOpen else na;
     PlotPMOLine.SetDefaultColor(CreateColor(77, 166, 255));
     PlotPMOLine.SetLineWeight(LineWidth);
     PlotPMOLine.SetPaintingStrategy(PaintingStrategy.DASHES);
     PlotPMOLine.HideTitle();
     PlotPMOLine.HideBubble();
Thanks for the rply, the chart is blank am i suppose to do something in the code ?
 
T

Trading51

Active member
2019 Donor
what I was trying to do is the following, at a certain time like 6 am or 10 am I wanted a horizontal line at the opening of the bar, so at 720 (6 am) and 240-minute bar (10 am) there would be a horizontal line to the right of the chart maybe not all the way across just by a margin, using this for $ES futures, the above code I tried to see if I could do something but not code orientated for that
 
G

GeneHo

New member
2019 Donor
VIP
Is there a script to draw horiz line of high / low of 1st bar (after market open), it can be in any time frame.
 

Similar threads

Top