here is my conversion. i added a few things.
i changed some colors. yellow or orange ? too close for me. i made it simple, red or green.
i don't like constants or specific averages, so i set them up, able to be changed.
i set up 5 averages, so they can be 1 of 5 types.
4 EMA , 1 MA
there are 2 variables, u_shape d_shape , which i guessed at determining when arrows are shown.
they seem to appear when wiz1 crosses 0, so not much use. default is off.
turned off
histogram1, has data from wiz1, and colors from wiz2
added a 2nd histogram , default on
histogram2, has data from wiz1, and colors from trig1
this signal seems interesting...
i added a line that has data from wiz1, with a factor applied. i didn't want a line covering up the ends of the histogram.
the colors are from trig1. same info as histogram2, just a different way of looking at the data.
i added a variable, that checks if wiz1 data , bar to bar, is getting flat. is the change < x% ?
if there are flat sections, histogram2 will have gray bars, and short gray lines will appear beyond the existing red/green line. i didn't want to change or cover up the main red/green colors.
default is , ignore_wiz1_change_per_below = 2.0
set to 0 to turn it off.
Ruby:
# ema_Full_Cycle_Half_Cycle_00c
# https://usethinkscript.com/threads/convert-tradingview-full-cycle-half-cycle.10968/
# convert Tradingview "Full Cycle Half Cycle"
# Ronathan Edwards 4/17 at 8:04 AM
# ..AverageTypes..
# EXPONENTIAL
# HULL
# SIMPLE
# WEIGHTED
# WILDERS
declare lower;
def na = double.nan;
def bn = barnumber();
# ignore if wiz1 signal is flat , bar to bar change < 5%
input ignore_wiz1_change_per_below = 2.0;
#hint ignore_wiz1_change_per_below: set to 0 to disable, else some % number, like 5
# last bar ( most recent)
#def lastbar = !isnan(close[0]) and isnan(close[-1]);
def price = ohlc4;
input ma1_len = 5;
input ma1_type = AverageType.EXPONENTIAL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);
input ma2_len = 10;
input ma2_type = AverageType.EXPONENTIAL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);
input ma3_len = 34;
input ma3_type = AverageType.EXPONENTIAL;
def ma3 = MovingAverage(ma3_type, price, ma3_len);
input ma4_len = 68;
input ma4_type = AverageType.EXPONENTIAL;
def ma4 = MovingAverage(ma3_type, price, ma3_len);
#wiz1 = ema(ohlc4,5) - ema(ohlc4,34)
def wiz1 = ma1 - ma3;
#wiz2 = ema(ohlc4,10) - ema(ohlc4,68)
def wiz2 = ma2 - ma4;
#trig1 = sma(wiz1,5)
input ma5_len = 5;
input ma5_type = AverageType.simple;
def trig1 = MovingAverage(ma5_type, wiz1, ma5_len);
def wiz1_diff = round(((wiz1 - wiz1[1])/wiz1[1])*100, 2);
def ignore_flat_wiz1 = if absvalue(wiz1_diff) < ignore_wiz1_change_per_below then 1 else 0;
#addchartbubble(1, wiz1, wiz1_diff, (if ignore_flat_wiz1 then color.gray else color.yellow), no);
input show_histogram1_wiz2_colors = no;
plot zh1 = if show_histogram1_wiz2_colors then wiz1 else na;
zh1.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
zh1.AssignValueColor(if ignore_flat_wiz1 then color.gray else if wiz2 > 0 then color.green else color.red);
zh1.setlineweight(2);
zh1.hidebubble();
#plot(wiz1, style=histogram, linewidth=4, color=c_color)
#c_color=wiz2 <= 0 ? red : lime
def u_shape = (wiz1 <= 0 and wiz2 >= 0);
def d_shape = (wiz1 > 0 and wiz2 <= 0);
input show_arrows = no;
def vert1 = 0.8;
plot zu = if (!show_arrows or !u_shape) then na else (min(0, wiz1)*(1+vert1));
zu.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zu.SetDefaultColor(Color.green);
zu.setlineweight(3);
zu.hidebubble();
plot zd = if (!show_arrows or !d_shape) then na else (max(0, wiz1)*(1+vert1));
zd.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zd.SetDefaultColor(Color.red);
zd.setlineweight(3);
zd.hidebubble();
input show_trig_line = yes;
def vert2 = 0.2;
# t_color = trig1 <= wiz1? yellow : orange
plot ztrig = if (!show_trig_line or isnan(close)) then na else wiz1*(1+vert2);
ztrig.AssignValueColor(if trig1 <= wiz1 then color.green else color.red);
ztrig.setlineweight(3);
ztrig.hidebubble();
#if ignore_flat_wiz1 then color.gray else
def gray_offset = 1.3;
plot ztrig_gray = if (!show_trig_line or isnan(close)) then na else if ignore_flat_wiz1 then wiz1*(gray_offset+vert2) else na;
#ztrig.AssignValueColor(if trig1 <= wiz1 then color.green else color.red);
ztrig_gray.SetDefaultColor(Color.gray);
ztrig_gray.setlineweight(4);
ztrig_gray.hidebubble();
# ignore_wiz1_changes_below
# histo2 - color with trig colors
input show_histogram2_trig_colors = yes;
plot zh2 = if show_histogram2_trig_colors then wiz1 else na;
zh2.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
zh2.AssignValueColor(if ignore_flat_wiz1 then color.gray else if trig1 <= wiz1 then color.green else color.red);
zh2.setlineweight(2);
zh2.hidebubble();
# show 0 line if no histo
plot zzero = if (show_histogram1_wiz2_colors or show_histogram2_trig_colors) then na else 0;
zzero.SetDefaultColor(Color.gray);
#zzero.setlineweight(1);
zzero.hidebubble();
# -----------------------------------------------------
#// author Gankiskahn personal study For Free Distribution study(title="Full cycle Half cycle", shorttitle="Wizard1")
#wiz1 = ema(ohlc4,5) - ema(ohlc4,34)
#wiz2 = ema(ohlc4,10) - ema(ohlc4,68)
#trig1 = sma(wiz1,5)
#c_color=wiz2 <= 0 ? red : lime
#u_shape=wiz1 <= 0 and wiz2 >= 0
#d_shape=wiz1 > 0 and wiz2 <= 0
#t_color=trig1 <= wiz1? yellow : orange
#plot(wiz1, style=histogram, linewidth=4, color=c_color)
#bgcolor(u_shape ? #FFFF00 : d_shape ? #FF00FF : na, transp=60)
#
COP 1hr 30day
histogram of wiz1
line of wiz1, with a factor applied, so it is slightly away from the histogram
colors are from , if trig1 <= wiz1 then color.green else color.red