Scan for entry and exit arrows in lower indicator?

S

Superfast

New member
Marketplace
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:
T

tomsk

Well-known member
VIP
Warehouse
@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:
S

Superfast

New member
Marketplace
Many thanks, I will look at the video and check the scan.
 
S

Superfast

New member
Marketplace
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.
 
D

diazlaz

Active member
VIP
Warehouse
Superfast - thanks for sharing. how do you trade this. It has great potential in the lower timeframes? have you tried this for intraday trading?
 
S

Superfast

New member
Marketplace
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.
 
D

diazlaz

Active member
VIP
Warehouse
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!
 

Top