Scan for entry and exit arrows in lower indicator?

Superfast

New member
How to create a scan for the entry and exit arrows in the lower indicator? This is part of another indicator.

See lower indicator below;

Code:
declare lower;

input showpositionbubble = yes;
input showentrybubble = yes;
input entryarrows = yes;
input STpricecolor = no;
input combopricecolor = yes;
input CCIATRPriceColor = no;
input alerts = no;
input showlocationbubble = no;
input Factor = 1.3;
input Pd = 60;
input Lookback = 3;
input usecloud = yes;
input vertLine = yes;
input lengthCCI = 20;
input lengthATR = 4;
input AtrFactor = 0.70;

def pricedata = HL2[Lookback];

DefineGlobalColor("TrendUp", CreateColor(0, 255, 255));
DefineGlobalColor("TrendDown", CreateColor(0, 102, 255));

def Up = pricedata - (Factor * ATR(Pd));
def Dn = pricedata + (Factor * ATR(Pd));

def TrendUp = if close[1] > TrendUp[1] then Max(Up, TrendUp[1]) else Up;
def TrendDown = if close[1] < TrendDown[1] then Min(Dn, TrendDown[1]) else Dn;

def Trend = if close > TrendDown[1] then 1 else if close < TrendUp[1] then -1 else (Trend[1]);

plot Tsl = if Trend == 1 then TrendUp else TrendDown;
Tsl.AssignValueColor(if Trend == 1 then GlobalColor("TrendUp") else GlobalColor("TrendDown")); #SuperTrend
Tsl.SetLineWeight(3);

plot entryArrow = (if Trend == 1 and Trend[1] == -1 then Trend else Double.NaN); #Up Entry Arrow
entryArrow.SetDefaultColor(Color.WHITE);
entryArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
entryarrow.SetHiding(!entryarrows);

plot exitArrow = (if Trend == -1 and Trend[1] == 1 then Trend else Double.NaN); #Down Entry Arrow
exitArrow.SetDefaultColor(Color.YELLOW);
exitArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
exitArrow.SetHiding(!entryarrows);
 
Last edited by a moderator:

tomsk

Well-known member
VIP
@Superfast you can usually reference your study in the scanner. Look at the video that @BenTen provided above.
However what I like to do is to convert the study to a scanable code.

Please see below - I have converted your study to a Scan. This assumes you want to scan for "entryArrow"
If you want to scan for "exitArrow", make sure you comment the two plot statements in the code like so

#plot entryArrow = Trend == 1 and Trend[1] == -1;
plot exitArrow = Trend == -1 and Trend[1] == 1;

Remember, the scanner only expects one plot statement or it will barf.
All the best! I tested this on a scan of the S&P 500 and it works great!

Code:
input Factor = 1.3;
input Pd = 60;
input Lookback = 3;

def pricedata = HL2[Lookback];
def Up = pricedata - (Factor * ATR(Pd));
def Dn = pricedata + (Factor * ATR(Pd));

def TrendUp = if close[1] > TrendUp[1] then Max(Up, TrendUp[1]) else Up;
def TrendDown = if close[1] < TrendDown[1] then Min(Dn, TrendDown[1]) else Dn;
def Trend = if close > TrendDown[1] then 1 else if close < TrendUp[1] then -1 else (Trend[1]);

# Comment out (#) Plot NOT wanted

plot entryArrow = Trend == 1 and Trend[1] == -1;
#plot exitArrow = Trend == -1 and Trend[1] == 1;
 
Last edited:

Superfast

New member
I have one further request. How do I get the scan to show all entry or exit arrows for a particular lookback period? I changed the lookback period from 3 to 10 and even 20 and it did not pull all the entrysignals. I am thinking it has to be shown as a range.
 

diazlaz

Well-known member
2019 Donor
VIP
Superfast - thanks for sharing. how do you trade this. It has great potential in the lower timeframes? have you tried this for intraday trading?
 

Superfast

New member
I sell puts and calls and use it on the daily and weekly timeframes. Where there's a entry arrow on the weekly or daily timeframe, I sell puts 30 days out, and where there is an exit arrow, I sell calls 30 days out. I don't use for the intraday trading, although I think it can work. I am exploring this now, hence the reason for asking for assistance on the scan.
 

diazlaz

Well-known member
2019 Donor
VIP
I sell puts and calls and use it on the daily and weekly timeframes. Where there's a entry arrow on the weekly or daily timeframe, I sell puts 30 days out, and where there is an exit arrow, I sell calls 30 days out. I don't use for the intraday trading, although I think it can work. I am exploring this now, hence the reason for asking for assistance on the scan.
I think you have a viable strategy and with minimal observations I think it could work well intraday. I will add this to backlog for additional testing.

All the best!
 

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top