The Edge by Robert Payne

P

Playstation

Active member
VIP
Hey @RobertPayne, I found this online by you years ago, hope you can shed some light.

Attached is the code, but I'm wondering how do I assignpricecolor when all bullish signals are lit up, and turn candles green? Vice versa for shorts red.

Code:
#The Edge
#Robert Payne

#Plot 8 period moving average
plot MA8 = Average(close, 8);
MA8.SetDefaultColor(Color.YELLOW);
MA8.SetLineWeight(2);

#Trend Signal
def TrendUp = if close > MA8 then 1 else Double.NaN;
def TrendDn  = if close < MA8 then 1 else Double.NaN;
AddLabel(TrendUp, "UP", Color.GREEN);
AddLabel(TrendDn, "DN", Color.RED);

#Net Signal
def NSup = if close - close(period = "day" )[1] > 0 then 1 else Double.NaN;
def NSdn = if close - close(period = "day" )[1] <= 0 then 1 else Double.NaN;
AddLabel(NSup, "NS", Color.GREEN);
AddLabel(NSdn, "NS", Color.RED);

#Open Signal
def OSup = if close - open(period = "day" ) > 0 then 1 else Double.NaN;
def OSdn = if close - open(period = "day" ) < 0 then 1 else Double.NaN;
AddLabel(OSup, "OS", Color.GREEN);
AddLabel(OSdn, "OS", Color.RED);

#High / Low Signal
def Higher = if close > high(period = "day" )[1] then 1 else Double.NaN;
def Lower = if close < low(period = "day" )[1] then 1 else Double.NaN;
def Neutral = if close <= high(period="day" )[1] and close >= low(period="day" )[1] then 1 else Double.NaN;
AddLabel(Higher, "H/L", Color.GREEN);
AddLabel(Lower, "H/L", Color.RED);
AddLabel(Neutral, "H/L", Color.GRAY);

#Out of Bounds
def sDev = StDev(close, 21);
def MidLine = Average(close, 21);
def UpperBand = MidLine + 2 * sDev;
def LowerBand = MidLine - 2 * sDev;
def CloseAbove = if close > UpperBand then 1 else Double.NaN;
def CloseBelow = if close < LowerBand then 1 else Double.NaN;
AddLabel(CloseAbove, round(close - UpperBand,2), Color.WHITE);
AddLabel(CloseBelow, round(close - LowerBand,2), Color.WHITE);
 
Last edited by a moderator:
P

Playstation

Active member
VIP
I tried to add:
def Bullish = Trendup + OSup + NSup;
def Bearish = Trenddn + OSdn + NSdn;

Assignpricecolor(if Bullish then Color.Green else Bearish then Color.Red else Color.Gray)

but failed miserably hahahah! Hope someone can help a little on this!
 
horserider

horserider

Well-known member
VIP
Assignpricecolor(if Bullish then Color.Green else Bearish then Color.Red else Color.Gray)

else if and ;
 
P

Playstation

Active member
VIP
Assignpricecolor(if Bullish then Color.Green else if Bearish then Color.Red else Color.Gray);

doesn't work though :unsure:
 
H

HighBredCloud

Well-known member
VIP
Assignpricecolor(if Bullish then Color.Green else Bearish then Color.Red else Color.Gray)

else if and ;

What else needs to be added to that line to have it work? It does not paint the candles and gives an error in the script.
 
P

Playstation

Active member
VIP
my logic is if Bullish then candles paint green
bearish then candles paint red
if 1 condition doesn't fulfill (Trendup OSup NSup), then candles remain gray
not sure if i explained correctly?
 
H

HighBredCloud

Well-known member
VIP
my logic is if Bullish then candles paint green
bearish then candles paint red
if 1 condition doesn't fulfill (Trendup OSup NSup), then candles remain gray
not sure if i explained correctly?
How about just to paint the candles GREEN and RED based on the above and below the line?
 
P

Playstation

Active member
VIP
Robert's logic is all 3 signals must lit green or all 3 red before any entry.
if there's dissonance, no go.
 
H

HighBredCloud

Well-known member
VIP
Robert's logic is all 3 signals must lit green or all 3 red before any entry.
if there's dissonance, no go.


I am not a coder...but this is what I found that uses 3 signals for entry...not sure if that would help you in anyway...

DefineGlobalColor("bullish", Color.green);
DefineGlobalColor("neutral", Color.BLUE);
DefineGlobalColor("bearish", Color.red);
AssignPriceColor( if bullish then GlobalColor("bullish" ) else if bearish then GlobalColor("bearish" ) else GlobalColor("neutral" ));
 
horserider

horserider

Well-known member
VIP
Assignpricecolor(if Bullish then Color.Green else if Bearish then Color.Red else Color.Gray);

This will not give an error. No idea if it paints the candles as you wish. I was just correcting your script errors. Not looked at the study at all.
 
H

HighBredCloud

Well-known member
VIP
@Playstation Dude...I don't know if this works...but this is what I came up with...it just painted ONE candle GREEN...

def Bullish = Trendup + OSup + NSup;
def Bearish = Trenddn + OSdn + NSdn;

AssignPriceColor( if bullish then Color.GREEN else if bearish then Color.RED else Color.Light_Gray);
 
J007RMC

J007RMC

Well-known member
2019 Donor
VIP
I leaavitt projection set to 15ma and the edge is default 8 ma perhaps another confirmation idk.

Code:
# Leavitt, Jay A., PhD [2017]. “Beyond The Hull With Leavitt Projections,” Technical Analysis of StockS & commoditieS, Volume 35: February.


script LeavittProjection{
input y = close;
input n = 20;
rec x = x[1] + 1;
def a = (n * sum(x * y, n) - sum(x, n) * sum(y, n) ) / ( n *sum(Sqr(x), n) - Sqr(sum(x, n)));
def b = (sum(Sqr(x), n) * sum(y, n) - sum(x, n) * sum(x *y, n) ) / ( n * sum(Sqr(x), n) - Sqr(sum(x, n)));
plot LeavittProjection= a*x+ b;
}

script LeavittConvolution
{ input   price = close;
input n = 20;
def intLength = Floor(Sqrt(n));

plot LeavittConvolution = LeavittProjection (LeavittProjection (price, n), intLength);
}
def price = Close;
input length = 9;

def intLength = Floor(Sqrt(length));
plot LeavittConvolution = LeavittProjection (LeavittProjection (price, length), intLength);
LeavittConvolution.AssignValueColor(if LeavittConvolution > LeavittConvolution [1] then Color.GREEN else Color.RED);
 
Last edited by a moderator:
T

tradegeek

Active member
2019 Donor
VIP
I'm not a coder but I messed with the code and this works...please confirm.


Code:
def Bullish = TrendUp and NSup and OSup;
def Bearish = TrendDn and NSdn and OSdn;

AssignPriceColor(if Bullish is true then Color.GREEN else if Bearish is true then Color.RED else Color.GRAY);
 
Thread starter Similar threads Forum Replies Date
S Display bubble on the right edge Questions 2

Similar threads

Top