TNTrader5159
Active member
How would one determine which occurred first in the current bar -- the high or the low? Can the time of each be called forth and compared?
How would one determine which occurred first in the current bar -- the high or the low? Can the time of each be called forth and compared?
How would one determine which occurred first in the current bar -- the high or the low? Can the time of each be called forth and compared?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
I see. I will have to break the current bar into at least two bars to make mostly sure the high engulfs the 3 preceding bars BEFORE the low does to indicate a Short alert at the latter. Or the opposite for a Long alert when the high break occurs AFTER the low break.As @halcyonguy pointed out, the ToS platform nor any other platform provides for "inter-candle" history.
The candle provides the open, close, high, low. It is not possible from that data to determine "when" they happened.
As @halcyonguy stated, you might be able to code an interpolation routine comparing the high and lows of the lower timeframes to create a guesstimate for which came first for the current aggregation on your chart.
close of the previous candle?How would one determine which occurred first in the current bar -- the high or the low? Can the time of each be called forth and compared?
No because the current candle/bar could open near there then go down first then back up and give what would in accord be a long signal when that might not be appropriate for conditions. I think cutting the timeframe into one-minute segments and comparing bar numbers of the high and low breaks is the only way to determine which would come first here.close of the previous candle?
Can you reference the current timeframe, eg if you're on a 10-minute bar chart, can you have some code return the value '10' so as to know how many bars to look at in comparing the bar numbers of the high and low breaks above/below the number of bars engulfed?I see. I will have to break the current bar into at least two bars to make mostly sure the high engulfs the 3 preceding bars BEFORE the low does to indicate a Short alert at the latter. Or the opposite for a Long alert when the high break occurs AFTER the low break.
Really my system is about TIME ratios not necessarily fixed bars that can only approximate that goal and thus yield fewer and less accurate trade detections. Ideally it would use 1-second intervals, but no market trades often enough throughout each session to make time a true representation. Events or volume are really what matter as with directional movement indicators. Are volume bars done in TS? I don't think so, but I'm not focusing there anyway. It's too complicated. I like simple.
So back to the more practical means to ends, breaking things down into 1-minute bars is the best way for TS to approximate the desired end result. For example, if one bar engulfs the preceding three bars, you have a 1/3 ratio or the minimum in my system. If two bars engulf six, the same ratio applies. The shortcut is to look at multiple timeframes at once to achieve the desired minimum ratio using a minimum number of variants without complicating things in using all the numerous possible ratio combinations for one fixed timeframe.
So first determine if one bar engulfs three, then which end engulfs them first (high for a short and low for a long) by breaking it down into a shorter base timeframe, then determine how many bars it actually does engulf, and keep it calibrating as the market moves favorably to possibly achieve a tradeable ratio on a longer timeframe to project a longer favorable move that would plow through more impedance. This is the key to determining what is elusive to most traders as the proper exit point.
Measure the number of bars engulfed against the "Impedance Factor" that would stand in the way as prior primary and secondary peaks and valleys and congestion zones. The bigger wins. I have a way to calculate congestion zones for comparison to pattern strength or the "Thrust Factor" that I will show later. With any trade entered, your profit objective is already known in advance. Stops should not be necessary in most cases, and should an adverse move occasionally occur, you can usually turn this into profit that more than offsets the small loss by reversing the position. More on that later. Of course, an emergency/catastrophe stop would be entered automatically with EVERY TRADE placed, unless it's a non-leveraged investment like option purchases. More on that later also.
All that's left is account management rules and to exit all positions before any holiday or weekend. Most trades would conclude intraday anyway, as the objective is to trade as short-term as possible to capture more market "surface area." In these crazy times, you don't want to leave yourself exposed during any significant breaks in trading where even a stop would not protect you should there be a catastrophic event.
events during a candle can't be saved, except high and low.
you would have to use a smaller time frame chart and compare bar numbers of the 2 events.
Can you reference the current timeframe, eg if you're on a 10-minute bar chart, can you have some code return the value '10' so as to know how many bars to look at in comparing the bar numbers of the high and low breaks above/below the number of bars engulfed?
How would one determine which occurred first in the current bar -- the high or the low? Can the time of each be called forth and compared?
Ruby:input agg = AggregationPeriod.TEN_MIN; def rth = Between(GetTime(), RegularTradingStart(GetYYYYMMDD()), RegularTradingEnd(GetYYYYMMDD())); plot hper = if !rth then Double.NaN else high(period = agg); plot lper = if !rth then Double.NaN else low(period = agg); hper.SetPaintingStrategy(PaintingStrategy.DASHES); lper.SetPaintingStrategy(PaintingStrategy.DASHES); hper.SetLineWeight(2); hper.SetDefaultColor(Color.GREEN); lper.SetDefaultColor(Color.RED); lper.SetLineWeight(2); #Define Bars in minutes in Agg input def bn = BarNumber(); input begin = 0930; input end = 1600; def bar = if SecondsFromTime(begin) < 0 and SecondsTillTime(end) > 0 then 0 else if SecondsTillTime(begin) == 0 and SecondsFromTime(begin) == 0 then 0 else bar[1] + 1; def minutes = GetValue(agg / 60000, 1); AddLabel(1, minutes); def barx_min = bar % ((minutes) / (GetAggregationPeriod() / 60000)) == 0; def barxct = if barx_min then 1 else barxct[1] + 1; #Identify Highs/Lows of the Agg Input def lastbubbleh = if high == hper then bn else lastbubbleh[1]; def lastbubblel = if low == lper then bn else lastbubblel[1]; #Vertical Lines seperate number of bars in Agg minutes AddVerticalLine(rth and barx_min, "", Color.WHITE); #Test to show Highs/Lows and Time Happened input test = yes; input timezone = {default "ET", "CT", "MT", "PT"}; def starthour = (if timezone == timezone."ET" then 9 else if timezone == timezone."CT" then 8 else if timezone == timezone."MT" then 7 else 6) ; def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60); def minutes_ = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60; AddChartBubble(test and bn == lastbubbleh, high(period = agg), #high + "\n" + lastbubbleh + "\n" + hour + ":" + (if minutes_ < 10 then "0" else "") + minutes_, Color.CYAN); AddChartBubble(test and bn == lastbubblel, low(period = agg), #low + "\n" + lastbubblel + "\n" + hour + ":" + (if minutes_ < 10 then "0" else "") + minutes_, Color.WHITE, no); #High or Low First Identified - If multiples of Highs/Lows, the latest bar is determinative of When Happened. For example, if a Low(agg) first appears then a singlar High(agg) appears and then another Low(agg) appears, as coded, then High would be first. AddChartBubble(barx_min[-1], if lastbubblel < lastbubbleh then low(period = agg) else high(period = agg), if lastbubblel < lastbubbleh then "L" else "H", if lastbubblel > lastbubbleh then Color.GREEN else Color.RED, if lastbubblel > lastbubbleh then yes else no); #Engulfing Candle def engulfingBar = if hper > hper[1] and lper < lper[1] then 1 else 0; AddChartBubble(engulfingBar, high(period = agg) + .02, "Engulfing", Color.MAGENTA);
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
W | Determining prior bar Close | Questions | 1 | |
Q | Determining a thread | Questions | 1 | |
Z | Determining the type of instruments | Questions | 2 | |
Option traders: how are you determining/allocating risk per trade right now? | Questions | 16 | ||
Determining a proper stop-loss on /ES Futures? | Questions | 11 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.