# Catching signal at market open

#### epete

##### Member
I have a strategy that will signal a change in trend by plotting an up arrow on the chart, indicating an uptrend and a down arrow, indicating a downtrend. Sometimes those signals happen before the market opens. After the market opens the trend could continue in an upward momentum. Any of a dozen trending indicators would be an example. Since I only trade during market hours - is there a way to detect the stock is in this "upward trend" at market open? In essence, the arrow signal has long since past, but I'd still like to catch the momentum at market open. Here's an example of a chart based on a CANDLE_TREND chart. The white arrow is the signal the trend has changed. I'd like to catch that at market open. The images on the right is the effect I'd like to achieve. Thanks

#### Attachments

• Catching-a-signal-at-open.jpg
4 KB · Views: 167
Last edited:
Solution
Here's a variation of the above question. I have signal arrows for up trend and down trend. Those are shown historically on the chart. Can I:
1. determine the time of the last up arrow
2. determine the time of the last down arrow
3. subtract the two, and therefore
4. know if the most recent signal was trending up - or trending down?

you can save the barnumber when a condition happens, then compare the 2 barnumbers.

Code:
``````def up = ... your  true/false trigger of the up arrow
def down = ...  your  true/false trigger of the down arrow

def upbn = if barnumber() == 1 then 0 else if up == 1 then barnumber() else upbn[1];
def downbn = if barnumber() == 1 then 0 else if down == 1 then barnumber() else downbn[1];

def...``````
I have a strategy that will signal a change in trend by plotting an up arrow on the chart, indicating an uptrend and a down arrow, indicating a downtrend. Sometimes those signals happen before the market opens. After the market opens the trend could continue in an upward momentum. Any of a dozen trending indicators would be an example. Since I only trade during market hours - is there a way to detect the stock is in this "upward trend" at market open? In essence, the arrow signal has long since past, but I'd still like to catch the momentum at market open. Here's an example of a chart based on a CANDLE_TREND chart. The white arrow is the signal the trend has changed. I'd like to catch that at market open. Thanks
Interesting, can you please post the "signal" or indicator that does this? Thanks.

Last edited:
Here's a variation of the above question. I have signal arrows for up trend and down trend. Those are shown historically on the chart. Can I:
1. determine the time of the last up arrow
2. determine the time of the last down arrow
3. subtract the two, and therefore
4. know if the most recent signal was trending up - or trending down?

Here's a variation of the above question. I have signal arrows for up trend and down trend. Those are shown historically on the chart. Can I:
1. determine the time of the last up arrow
2. determine the time of the last down arrow
3. subtract the two, and therefore
4. know if the most recent signal was trending up - or trending down?
You could set a condition (if statement) that scans for the up/down area within x number of candles….

You could set a condition (if statement) that scans for the up/down area within x number of candles….
Risto - Do you have example code that would do that?

I cannot post the indicator I use since it is commercial (TrendTraderPro); however there are several trending indicators one could review, including the Heiken_Ashi based one found here:

Or, another one based on the standard TD Ameritrade HullMovingAvg:
Interesting, I also have TrendTraderPro indicator, let me know which TimeFrame and setting you're using so that I can help you with the scanner. I have also noticed that... in some cases 30 or 15 min before the bell the trend will begin going up and if it's strong enough it will continue soaring... but as always, it's a pattern that it's seen in occasionally ... no strategy is 100% effective. I have also seen stocks with good up-trending momentum in the premarket and then just after the bell they sell off and gap down... so it depends, the market is uncertain, you cannot predict it but you can set your rules to trade, and if they meet then trigger.

Here's a variation of the above question. I have signal arrows for up trend and down trend. Those are shown historically on the chart. Can I:
1. determine the time of the last up arrow
2. determine the time of the last down arrow
3. subtract the two, and therefore
4. know if the most recent signal was trending up - or trending down?

you can save the barnumber when a condition happens, then compare the 2 barnumbers.

Code:
``````def up = ... your  true/false trigger of the up arrow
def down = ...  your  true/false trigger of the down arrow

def upbn = if barnumber() == 1 then 0 else if up == 1 then barnumber() else upbn[1];
def downbn = if barnumber() == 1 then 0 else if down == 1 then barnumber() else downbn[1];

def isup_recent = (up > down);
addlabel(1, "recent was " + (if isup_recent then "up" else "down"), (if isup_recent then color.green else color.red) );``````

87k+ Posts
476 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?