def referenceBarLow = if secondsToTime(0930)==0 then low else referenceBarLow[1];
Thanks for your reply. I need the reference bar so that I can get its low, high, open and close. How does your code work to get the high of the reference bar?Ruby:def referenceBarLow = if secondsToTime(0930)==0 then low else referenceBarLow[1];
In your code you seemed to define the reference bar as the bar at 9:30. I did the same. I just did the low of the candle, but replace 'low' with high, open or close to get the other data points.
def referenceBarLow = if SecondsFromTime(0930)==0 then low else referenceBarLow[1];
What is referenceBarLow[1] though. Is it a candle object? If so should it not be referenceBarLow[1].low and then I can get the high value as referenceBarLow[1].high?
But it doesn't compile if I try to treat referanceBarLow[1] as a candle object.
def referenceBarLow = if secondsTillTime(0930)==0 then low else referenceBarLow[1];
def lowerLowThanOpeningBar = if secondsTillTime(0930)!=0 then low < referenceBarLow[1] else 0;
alert(lowerLowThanOpeningBar,"This Bar Has Lower Low Than Reference Bar", alert.BAR, sound.CHIMES);
addchartbubble(lowerLowThanOpeningBar, high, "ALERT");
Thanks a lot. I really appreciate it. The code, works like a charm. But this one adds a bubble and alerts every time it finds a lower bar than the referenceBarLow. How do I stop showing bubble once it is shown? Only one alert and one bubble between regulartradingstart(getyyyymmdd()) and regulartradingend(getyyyymmdd()). Thanks.referenceBarLow[1] is the value of referenceBarLow from the last bar. Setting referenceBarLow = referenceBarLow[1] allows you to store the value of the first bar low through the trading day. The code to your problem statement is below. I encourage you to use labels and chart bubbles to see what the code is doing. If you want the reference bar to be the first bar on the chart (instead of the 9:30 bar) then search this site for "firstbarofday".
Ruby:def referenceBarLow = if secondsTillTime(0930)==0 then low else referenceBarLow[1]; def lowerLowThanOpeningBar = if secondsTillTime(0930)!=0 then low < referenceBarLow[1] else 0; alert(lowerLowThanOpeningBar,"This Bar Has Lower Low Than Reference Bar", alert.BAR, sound.CHIMES); addchartbubble(lowerLowThanOpeningBar, high, "ALERT");
def referenceBarLow = if secondsTillTime(0930)==0 then low else referenceBarLow[1];
def lowerLowThanOpeningBar = if secondsFromTime(0930) > 0 and secondsTillTime(1600) > 0 then low < referenceBarLow[1] else 0;
def conditionCount = if secondsTillTime(0930)==0 then 0 else if lowerLowThanOpeningBar then conditionCount[1]+1 else conditionCount[1];
alert(conditionCount == 1 && lowerLowThanOpeningBar,"This Bar Has Lower Low Than Reference Bar", alert.BAR, sound.CHIMES);
addchartbubble(conditionCount == 1 && lowerLowThanOpeningBar, high, "ALERT");
It works. Thank you so much. In my mind I was going crazy thinking I have to use fold and all. You made it very simple. I have modified your code to track both the first high and first low during the market open.Ruby:def referenceBarLow = if secondsTillTime(0930)==0 then low else referenceBarLow[1]; def lowerLowThanOpeningBar = if secondsFromTime(0930) > 0 and secondsTillTime(1600) > 0 then low < referenceBarLow[1] else 0; def conditionCount = if secondsTillTime(0930)==0 then 0 else if lowerLowThanOpeningBar then conditionCount[1]+1 else conditionCount[1]; alert(conditionCount == 1 && lowerLowThanOpeningBar,"This Bar Has Lower Low Than Reference Bar", alert.BAR, sound.CHIMES); addchartbubble(conditionCount == 1 && lowerLowThanOpeningBar, high, "ALERT");
def referenceBarLow = if secondsTillTime(0930)==0 then low else referenceBarLow[1];
def lowerLowThanOpeningBar = if secondsFromTime(0930) > 0 and secondsTillTime(1600) > 0 then low < referenceBarLow[1] else 0;
def lowConditionCount = if secondsTillTime(0930)==0 then 0 else if lowerLowThanOpeningBar then lowConditionCount[1]+1 else lowConditionCount[1];
alert(lowConditionCount == 1 && lowerLowThanOpeningBar,"This Bar has Lower Low Than Reference Bar", alert.BAR, sound.CHIMES);
addchartbubble(lowConditionCount == 1 && lowerLowThanOpeningBar, high, “L”, Color.RED);
def referenceBarHigh = if secondsTillTime(0930)==0 then high else referenceBarHigh[1];
def higherHighThanOpeningBar = if secondsFromTime(0930) > 0 and secondsTillTime(1600) > 0 then high > referenceBarHigh[1] else 0;
def highConditionCount = if secondsTillTime(0930)==0 then 0 else if higherHighThanOpeningBar then highConditionCount[1]+1 else highConditionCount[1];
alert(highConditionCount == 1 && higherHighThanOpeningBar,"This Bar has Higher High Than Reference Bar", alert.BAR, sound.CHIMES);
addchartbubble(highConditionCount == 1 && higherHighThanOpeningBar, high, “H”, Color.GREEN);
Here it is. Thanks againYou just have to add one more condition to the alert statements. Everything you need is there. Let me know what you come up with.
def referenceBarLow = if secondsTillTime(0930)==0 then low else referenceBarLow[1];
def lowerLowThanOpeningBar = if secondsFromTime(0930) > 0 and secondsTillTime(1600) > 0 then low < referenceBarLow[1] else 0;
def lowConditionCount = if secondsTillTime(0930)==0 then 0 else if lowerLowThanOpeningBar then lowConditionCount[1]+1 else lowConditionCount[1];
def referenceBarHigh = if secondsTillTime(0930)==0 then high else referenceBarHigh[1];
def higherHighThanOpeningBar = if secondsFromTime(0930) > 0 and secondsTillTime(1600) > 0 then high > referenceBarHigh[1] else 0;
def highConditionCount = if secondsTillTime(0930)==0 then 0 else if higherHighThanOpeningBar then highConditionCount[1]+1 else highConditionCount[1];
alert(lowConditionCount == 1 && highConditionCount == 0 && lowerLowThanOpeningBar,"This Bar has Lower Low Than Reference Bar", alert.BAR, sound.CHIMES);
alert(highConditionCount == 1 && lowConditionCount == 0 && higherHighThanOpeningBar,"This Bar has Higher High Than Reference Bar", alert.BAR, sound.CHIMES);
addchartbubble(highConditionCount == 1 && lowConditionCount == 0 && higherHighThanOpeningBar, high, “H”, Color.GREEN);
addchartbubble(lowConditionCount == 1 && highConditionCount == 0 && lowerLowThanOpeningBar, high, “L”, Color.RED);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Finding Highest Bar in Awesome Oscillator | Questions | 1 | ||
Finding Last Value of an Array | Questions | 1 | ||
G | Help finding previous peaks | Questions | 2 | |
Finding Trending Dips | Questions | 8 | ||
E | Finding candlesticks | Questions | 0 |
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.