Maximum and minimum relative EWO

Pabloadmin

New member
Hi, i trying to get the maximum and minimum relative values from the Elliot wave oscillator like the marks in the graph. Some body could help me? This is the code of ewo osc:

# Elliot Wave Oscillator with bands
#Horserider 5/17/2020
# Normal : Fast SMA 5 – Slow SMA 35
# Fast: Fast SMA 5 – Slow SMA 17
# Slow: Fast SMA 10 – Slow SMA 70
#
declare lower;

input price = hl2;
input HistoType = {default STD, ROC};
input SmoothLength = 7;

def valueDiff;
def value;
def showBands;
switch (HistoType) {
case STD:
value = double.nan;
valueDiff = (Average(price, 5) - Average(price, 34));
#valueDiff = (movAvgWeighted(price, 5) - movAvgWeighted(price, 35));
#valueDiff = (hullMovingAvg(price, 5) - hullMovingAvg(price, 35));
showBands = 1;
case ROC:
# ROC is smoothed with a SMA
value = (Average(price, 10) - Average(price, 70));
valueDiff = Average(value - value[1], SmoothLength);
showBands = 1;
}

# --- start Breakout Bands logic ---
#
# AdvanceGetOscillator Breakout Bands logic ported
# from [codebase.mql4.com]
# and [fxcodebase.com]...

def coeff_num = 2;
def coeff_denom = 39;

def barNum = if IsNaN( close ) then Double.NaN else barNumber();
def coeff = coeff_num / ( coeff_denom + 1 );
def diff = ValueDiff;

rec _upLine = if barNum == 1 then
if diff >= 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff >= 0 then
diff * coeff + _upLine[1] * ( 1 - Coeff )
else
_upLine[1];
rec _dnLine = if barNum == 1 then
if diff < 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff < 0 then
diff * coeff + _dnLine[1] * ( 1 - Coeff )
else
_dnLine[1];

plot UpLine = if showBands then _upLine else double.nan;
plot DownLine = if showBands then _dnLine else double.nan;

UpLine.SetDefaultColor(GetColor(9));
UpLine.SetLineWeight(2);
DownLine.SetDefaultColor(GetColor(9));
DownLine.SetLineWeight(2);

# --- end Breakout Band logic ---
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(7));
plot Osc = valueDiff;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;


Osc.SetDefaultColor(GetColor(5));
Osc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Osc.SetLineWeight(3);
Osc.DefineColor("Positive and Up", Color.GREEN);
Osc.DefineColor("Positive and Down", Color.DARK_GREEN);
Osc.DefineColor("Negative and Down", Color.RED);
Osc.DefineColor("Negative and Up", Color.DARK_RED);
Osc.AssignValueColor(if Osc >= 0 then if Osc > Osc[1] then Osc.color("Positive and Up") else Osc.color("Positive and Down") else if Osc < Osc[1] then Osc.color("Negative and Down") else Osc.color("Negative and Up"));

ewo.jpg
 

Attachments

  • ewo.jpg
    ewo.jpg
    60.7 KB · Views: 209
Hi, i trying to get the maximum and minimum relative values from the Elliot wave oscillator like the marks in the graph. Some body could help me? This is the code of ewo osc:

# Elliot Wave Oscillator with bands
#Horserider 5/17/2020
# Normal : Fast SMA 5 – Slow SMA 35
# Fast: Fast SMA 5 – Slow SMA 17
# Slow: Fast SMA 10 – Slow SMA 70
#
declare lower;

input price = hl2;
input HistoType = {default STD, ROC};
input SmoothLength = 7;

def valueDiff;
def value;
def showBands;
switch (HistoType) {
case STD:
value = double.nan;
valueDiff = (Average(price, 5) - Average(price, 34));
#valueDiff = (movAvgWeighted(price, 5) - movAvgWeighted(price, 35));
#valueDiff = (hullMovingAvg(price, 5) - hullMovingAvg(price, 35));
showBands = 1;
case ROC:
# ROC is smoothed with a SMA
value = (Average(price, 10) - Average(price, 70));
valueDiff = Average(value - value[1], SmoothLength);
showBands = 1;
}

# --- start Breakout Bands logic ---
#
# AdvanceGetOscillator Breakout Bands logic ported
# from [codebase.mql4.com]
# and [fxcodebase.com]...

def coeff_num = 2;
def coeff_denom = 39;

def barNum = if IsNaN( close ) then Double.NaN else barNumber();
def coeff = coeff_num / ( coeff_denom + 1 );
def diff = ValueDiff;

rec _upLine = if barNum == 1 then
if diff >= 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff >= 0 then
diff * coeff + _upLine[1] * ( 1 - Coeff )
else
_upLine[1];
rec _dnLine = if barNum == 1 then
if diff < 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff < 0 then
diff * coeff + _dnLine[1] * ( 1 - Coeff )
else
_dnLine[1];

plot UpLine = if showBands then _upLine else double.nan;
plot DownLine = if showBands then _dnLine else double.nan;

UpLine.SetDefaultColor(GetColor(9));
UpLine.SetLineWeight(2);
DownLine.SetDefaultColor(GetColor(9));
DownLine.SetLineWeight(2);

# --- end Breakout Band logic ---
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(7));
plot Osc = valueDiff;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;


Osc.SetDefaultColor(GetColor(5));
Osc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Osc.SetLineWeight(3);
Osc.DefineColor("Positive and Up", Color.GREEN);
Osc.DefineColor("Positive and Down", Color.DARK_GREEN);
Osc.DefineColor("Negative and Down", Color.RED);
Osc.DefineColor("Negative and Up", Color.DARK_RED);
Osc.AssignValueColor(if Osc >= 0 then if Osc > Osc[1] then Osc.color("Positive and Up") else Osc.color("Positive and Down") else if Osc < Osc[1] then Osc.color("Negative and Down") else Osc.color("Negative and Up"));

i'm not quite sure what you want.
you didn't say what you want to see.
i don't know what max relative is.
i can't see any marks in your image. next time use a high contrast color.

here is my guess,
..find the max value of each positive section of the histogram
..find the min value of each negative section of the histogram

draw a blue line at the levels
show labels, that show the last value


Code:
# elliot_minmax_histo

#https://usethinkscript.com/threads/maximum-and-minimum-relative-ewo.16709/
#Maximum and minimum relative EWO

# Elliot Wave Oscillator with bands
#Horserider 5/17/2020
# Normal : Fast SMA 5 – Slow SMA 35
# Fast: Fast SMA 5 – Slow SMA 17
# Slow: Fast SMA 10 – Slow SMA 70

declare lower;

def na = double.nan;
def bn = barnumber();

input price = hl2;
input HistoType = {default STD, ROC};
input SmoothLength = 7;

def valueDiff;
def value;
def showBands;
switch (HistoType) {
case STD:
value = double.nan;
valueDiff = (Average(price, 5) - Average(price, 34));
#valueDiff = (movAvgWeighted(price, 5) - movAvgWeighted(price, 35));
#valueDiff = (hullMovingAvg(price, 5) - hullMovingAvg(price, 35));
showBands = 1;
case ROC:
# ROC is smoothed with a SMA
value = (Average(price, 10) - Average(price, 70));
valueDiff = Average(value - value[1], SmoothLength);
showBands = 1;
}

# --- start Breakout Bands logic ---
#
# AdvanceGetOscillator Breakout Bands logic ported
# from [codebase.mql4.com]
# and [fxcodebase.com]...

def coeff_num = 2;
def coeff_denom = 39;

def barNum = if IsNaN( close ) then Double.NaN else barNumber();
def coeff = coeff_num / ( coeff_denom + 1 );
def diff = ValueDiff;

rec _upLine = if barNum == 1 then
if diff >= 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff >= 0 then
diff * coeff + _upLine[1] * ( 1 - Coeff )
else
_upLine[1];
rec _dnLine = if barNum == 1 then
if diff < 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff < 0 then
diff * coeff + _dnLine[1] * ( 1 - Coeff )
else
_dnLine[1];

plot UpLine = if showBands then _upLine else double.nan;
plot DownLine = if showBands then _dnLine else double.nan;

UpLine.SetDefaultColor(GetColor(9));
UpLine.SetLineWeight(2);
DownLine.SetDefaultColor(GetColor(9));
DownLine.SetLineWeight(2);

# --- end Breakout Band logic ---
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(7));
plot Osc = valueDiff;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;


Osc.SetDefaultColor(GetColor(5));
Osc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Osc.SetLineWeight(3);
Osc.DefineColor("Positive and Up", Color.GREEN);
Osc.DefineColor("Positive and Down", Color.DARK_GREEN);
Osc.DefineColor("Negative and Down", Color.RED);
Osc.DefineColor("Negative and Up", Color.DARK_RED);
Osc.AssignValueColor(if Osc >= 0 then if Osc > Osc[1] then Osc.color("Positive and Up") else Osc.color("Positive and Down") else if Osc < Osc[1] then Osc.color("Negative and Down") else Osc.color("Negative and Up"));


# determine first section , pos or neg
# histo data = valueDiff

def dir = if valueDiff > 0 then 1
 else if valueDiff < 0 then -1
 else 0;

def n = 1000;

def hi;
def lo;
if (bn == 1 and dir > 0) or (dir[1] <= 0 and dir > 0) then {
# positive histo
 hi = fold i1 = 0 to n
 with p1
 while getvalue(dir, -i1) > 0
 do max(getvalue(valueDiff,-i1), p1);
 lo = na;

} else if bn == 1 and dir < 0 or (dir[1] >= 0 and dir < 0) then {
# negative histo
 hi = na;
 lo = fold i2 = 0 to n
 with p2
 while getvalue(dir, -i2) < 0
 do min(getvalue(valueDiff,-i2), p2);

} else {
 hi = hi[1];
 lo = lo[1];
}


plot zhi = if !isnan(close) then hi else na;
plot zlo = if !isnan(close) then lo else na;
zhi.SetDefaultColor(Color.cyan);
zhi.hidebubble();
zlo.SetDefaultColor(Color.cyan);
zlo.hidebubble();

addlabel(1, hi + " highest", color.yellow);
addlabel(1, lo + " lowest", color.yellow);
#

XmMxW2o.jpg
 
i'm not quite sure what you want.
you didn't say what you want to see.
i don't know what max relative is.
i can't see any marks in your image. next time use a high contrast color.

here is my guess,
..find the max value of each positive section of the histogram
..find the min value of each negative section of the histogram

draw a blue line at the levels
show labels, that show the last value


Code:
# elliot_minmax_histo

#https://usethinkscript.com/threads/maximum-and-minimum-relative-ewo.16709/
#Maximum and minimum relative EWO

# Elliot Wave Oscillator with bands
#Horserider 5/17/2020
# Normal : Fast SMA 5 – Slow SMA 35
# Fast: Fast SMA 5 – Slow SMA 17
# Slow: Fast SMA 10 – Slow SMA 70

declare lower;

def na = double.nan;
def bn = barnumber();

input price = hl2;
input HistoType = {default STD, ROC};
input SmoothLength = 7;

def valueDiff;
def value;
def showBands;
switch (HistoType) {
case STD:
value = double.nan;
valueDiff = (Average(price, 5) - Average(price, 34));
#valueDiff = (movAvgWeighted(price, 5) - movAvgWeighted(price, 35));
#valueDiff = (hullMovingAvg(price, 5) - hullMovingAvg(price, 35));
showBands = 1;
case ROC:
# ROC is smoothed with a SMA
value = (Average(price, 10) - Average(price, 70));
valueDiff = Average(value - value[1], SmoothLength);
showBands = 1;
}

# --- start Breakout Bands logic ---
#
# AdvanceGetOscillator Breakout Bands logic ported
# from [codebase.mql4.com]
# and [fxcodebase.com]...

def coeff_num = 2;
def coeff_denom = 39;

def barNum = if IsNaN( close ) then Double.NaN else barNumber();
def coeff = coeff_num / ( coeff_denom + 1 );
def diff = ValueDiff;

rec _upLine = if barNum == 1 then
if diff >= 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff >= 0 then
diff * coeff + _upLine[1] * ( 1 - Coeff )
else
_upLine[1];
rec _dnLine = if barNum == 1 then
if diff < 0 then
diff * coeff + diff * ( 1 - Coeff )
else
0
else
if diff < 0 then
diff * coeff + _dnLine[1] * ( 1 - Coeff )
else
_dnLine[1];

plot UpLine = if showBands then _upLine else double.nan;
plot DownLine = if showBands then _dnLine else double.nan;

UpLine.SetDefaultColor(GetColor(9));
UpLine.SetLineWeight(2);
DownLine.SetDefaultColor(GetColor(9));
DownLine.SetLineWeight(2);

# --- end Breakout Band logic ---
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(7));
plot Osc = valueDiff;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;


Osc.SetDefaultColor(GetColor(5));
Osc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Osc.SetLineWeight(3);
Osc.DefineColor("Positive and Up", Color.GREEN);
Osc.DefineColor("Positive and Down", Color.DARK_GREEN);
Osc.DefineColor("Negative and Down", Color.RED);
Osc.DefineColor("Negative and Up", Color.DARK_RED);
Osc.AssignValueColor(if Osc >= 0 then if Osc > Osc[1] then Osc.color("Positive and Up") else Osc.color("Positive and Down") else if Osc < Osc[1] then Osc.color("Negative and Down") else Osc.color("Negative and Up"));


# determine first section , pos or neg
# histo data = valueDiff

def dir = if valueDiff > 0 then 1
 else if valueDiff < 0 then -1
 else 0;

def n = 1000;

def hi;
def lo;
if (bn == 1 and dir > 0) or (dir[1] <= 0 and dir > 0) then {
# positive histo
 hi = fold i1 = 0 to n
 with p1
 while getvalue(dir, -i1) > 0
 do max(getvalue(valueDiff,-i1), p1);
 lo = na;

} else if bn == 1 and dir < 0 or (dir[1] >= 0 and dir < 0) then {
# negative histo
 hi = na;
 lo = fold i2 = 0 to n
 with p2
 while getvalue(dir, -i2) < 0
 do min(getvalue(valueDiff,-i2), p2);

} else {
 hi = hi[1];
 lo = lo[1];
}


plot zhi = if !isnan(close) then hi else na;
plot zlo = if !isnan(close) then lo else na;
zhi.SetDefaultColor(Color.cyan);
zhi.hidebubble();
zlo.SetDefaultColor(Color.cyan);
zlo.hidebubble();

addlabel(1, hi + " highest", color.yellow);
addlabel(1, lo + " lowest", color.yellow);
#

XmMxW2o.jpg
Yes @halcyonguy, thanks!
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
206 Online
Create Post

Similar threads

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.
Back
Top