Hi,
Anyone able to help converting this into TOS? Thanks in advance!
https://www.tradingview.com/v/ri7P5Cvh/
Anyone able to help converting this into TOS? Thanks in advance!
https://www.tradingview.com/v/ri7P5Cvh/
Last edited by a moderator:
find belowHi,
Anyone able to help converting this into TOS? Thanks in advance!
https://www.tradingview.com/v/ri7P5Cvh/
study("Heikin/Kaufman Strategy ",shorttitle="KAMA",overlay=true)
res1 = input(title="Heikin Ashi EMA Time Frame", type=resolution, defval="D")
test = input(0,"Heikin Ashi EMA Shift")
sloma = input(20,"Slow EMA Period")
//Kaufman MAK
Length = input(5, minval=1)
xPrice = input(hlc3)
xvnoise = abs(xPrice - xPrice[1])
Fastend = input(2.5,step=.5)
Slowend = input(20)
nfastend = 2/(Fastend + 1)
nslowend = 2/(Slowend + 1)
nsignal = abs(xPrice - xPrice[Length])
nnoise = sum(xvnoise, Length)
nefratio = iff(nnoise != 0, nsignal / nnoise, 0)
nsmooth = pow(nefratio * (nfastend - nslowend) + nslowend, 2)
nAMA = nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1]))
//Heikin Ashi Open/Close Price
ha_t = heikinashi(tickerid)
ha_close = security(ha_t, period, nAMA)
mha_close = security(ha_t, res1, hlc3)
//Moving Average
fma = ema(mha_close[test],1)
sma = ema(ha_close,sloma)
plot(fma,title="MA",color=black,linewidth=2,style=line)
plot(sma,title="SMA",color=red,linewidth=2,style=line)
plotshape(crossover(fma,sma), style=shape.triangleup, location=location.belowbar, size=size.small, color=green, text="B")
plotshape(crossunder(fma,sma), style=shape.triangledown, location=location.abovebar, size=size.small, color=red, text="S")
#https://www.tradingview.com/v/ri7P5Cvh/
#@TradeAlchemy
#study("Heikin/Kaufman Strategy ",shorttitle="KAMA",overlay=true)
# Converted by Sam4Cok@Samer800 - 05/2023
input HeikinAshiTimeframe = AggregationPeriod.DAY; # "Heikin Ashi EMA Time Frame"
input HeikinAshiShift = 0; # "Heikin Ashi EMA Shift"
input slowEmaPeriod = 20;#,"Slow EMA Period")
input Length = 5;
input Source = hlc3;
input kamaFastEnd = 2.5;
input kamaSlowEnd = 20;
def na = Double.NaN;
def last = isNaN(close);
def h = high(Period=HeikinAshiTimeframe);
def l = low(Period=HeikinAshiTimeframe);
def o = open(Period=HeikinAshiTimeframe);
def c = close(Period=HeikinAshiTimeframe);
#-----Color
DefineGlobalColor("fuchsia", CreateColor(255, 0, 255));
DefineGlobalColor("purple" , CreateColor(128, 0, 128));
DefineGlobalColor("blue" , CreateColor(0, 0, 255));
DefineGlobalColor("black" , Color.DARK_GRAY);#CreateColor(238,242,17));
DefineGlobalColor("lime" , CreateColor(0, 255, 0));
DefineGlobalColor("green" , CreateColor(0, 128, 0));
DefineGlobalColor("yellow" , CreateColor(255, 255, 0));
DefineGlobalColor("orange" , CreateColor(255, 127, 0));
#//KAMA
#kama(a, b)=>
script kama {
input price = hlc3;
input length = 5;
input fast = 2.5;
input slow = 20;
def xvnoise = AbsValue(Price - Price[1]);
def nfastend = 2/(Fast + 1);
def nslowend = 2/(Slow + 1);
def nsignal = AbsValue(Price - Price[Length]);
def nnoise = sum(xvnoise, Length);
def nefratio = if(nnoise != 0, nsignal / nnoise, 0);
def nsmooth = power(nefratio * (nfastend - nslowend) + nslowend, 2);
def nAMA = CompoundValue(1, nAMA[1] + nsmooth * (Price - nAMA[1]), Price);
plot out = nAMA;
}
def haClose = (o + h + l + c) / 4;
def haOpen = if isNaN(haopen[1]) then (o + c) / 2 else (haopen[1] + haclose[1]) / 2;
def haHigh = Max(h,max(haOpen, haClose));
def haLow = Min(l,min(haOpen, haClose));
def hahlc3 = (haHigh+haLow+haClose) / 3;
def ha_close = kama(Source, Length, kamaFastEnd, kamaSlowEnd);
def mha_close = hahlc3;
#//Moving Average
def fma = ExpAverage(mha_close,1);
def sma = ExpAverage(ha_close,slowEmaPeriod);
def col = sma>sma[1];
plot smaPlot = sma; # "SMA"
plot fmaPlot = if last then na else fma[HeikinAshiShift]; # "MA"
smaPlot.AssignValueColor(if col then Color.GREEN else Color.RED);
fmaPlot.SetDefaultColor(Color.GRAY);
AddChartBubble((fmaPlot crosses above smaPlot), low, "B", Color.GREEN, no);
AddChartBubble((fmaPlot crosses below smaPlot), high, "S", Color.RED , yes);
#-- END of CODE
@samer800 great job like always, a quick question or request. Do you think it is possible to add the scan for a swing trade? thank you in advance. other request sorry to bother you, i really like paint a candle Green with a Buy signal, and Red for a short signal.find below
CSS:#https://www.tradingview.com/v/ri7P5Cvh/ #@TradeAlchemy #study("Heikin/Kaufman Strategy ",shorttitle="KAMA",overlay=true) # Converted by Sam4Cok@Samer800 - 05/2023 input HeikinAshiTimeframe = AggregationPeriod.DAY; # "Heikin Ashi EMA Time Frame" input HeikinAshiShift = 0; # "Heikin Ashi EMA Shift" input slowEmaPeriod = 20;#,"Slow EMA Period") input Length = 5; input Source = hlc3; input kamaFastEnd = 2.5; input kamaSlowEnd = 20; def na = Double.NaN; def last = isNaN(close); def h = high(Period=HeikinAshiTimeframe); def l = low(Period=HeikinAshiTimeframe); def o = open(Period=HeikinAshiTimeframe); def c = close(Period=HeikinAshiTimeframe); #-----Color DefineGlobalColor("fuchsia", CreateColor(255, 0, 255)); DefineGlobalColor("purple" , CreateColor(128, 0, 128)); DefineGlobalColor("blue" , CreateColor(0, 0, 255)); DefineGlobalColor("black" , Color.DARK_GRAY);#CreateColor(238,242,17)); DefineGlobalColor("lime" , CreateColor(0, 255, 0)); DefineGlobalColor("green" , CreateColor(0, 128, 0)); DefineGlobalColor("yellow" , CreateColor(255, 255, 0)); DefineGlobalColor("orange" , CreateColor(255, 127, 0)); #//KAMA #kama(a, b)=> script kama { input price = hlc3; input length = 5; input fast = 2.5; input slow = 20; def xvnoise = AbsValue(Price - Price[1]); def nfastend = 2/(Fast + 1); def nslowend = 2/(Slow + 1); def nsignal = AbsValue(Price - Price[Length]); def nnoise = sum(xvnoise, Length); def nefratio = if(nnoise != 0, nsignal / nnoise, 0); def nsmooth = power(nefratio * (nfastend - nslowend) + nslowend, 2); def nAMA = CompoundValue(1, nAMA[1] + nsmooth * (Price - nAMA[1]), Price); plot out = nAMA; } def haClose = (o + h + l + c) / 4; def haOpen = if isNaN(haopen[1]) then (o + c) / 2 else (haopen[1] + haclose[1]) / 2; def haHigh = Max(h,max(haOpen, haClose)); def haLow = Min(l,min(haOpen, haClose)); def hahlc3 = (haHigh+haLow+haClose) / 3; def ha_close = kama(Source, Length, kamaFastEnd, kamaSlowEnd); def mha_close = hahlc3; #//Moving Average def fma = ExpAverage(mha_close,1); def sma = ExpAverage(ha_close,slowEmaPeriod); def col = sma>sma[1]; plot smaPlot = sma; # "SMA" plot fmaPlot = if last then na else fma[HeikinAshiShift]; # "MA" smaPlot.AssignValueColor(if col then Color.GREEN else Color.RED); fmaPlot.SetDefaultColor(Color.GRAY); AddChartBubble((fmaPlot crosses above smaPlot), low, "B", Color.GREEN, no); AddChartBubble((fmaPlot crosses below smaPlot), high, "S", Color.RED , yes); #-- END of CODE
hi @samer800 i hope you can help me with this request. thank you in advance@samer800 great job like always, a quick question or request. Do you think it is possible to add the scan for a swing trade? thank you in advance. other request sorry to bother you, i really like paint a candle Green with a Buy signal, and Red for a short signal.
add this for Candle Color@samer800 great job like always, a quick question or request. Do you think it is possible to add the scan for a swing trade? thank you in advance. other request sorry to bother you, i really like paint a candle Green with a Buy signal, and Red for a short signal.
hi @samer800 i hope you can help me with this request. thank you in advance
def long = (fmaPlot > smaPlot) and (fmaPlot[1] <= smaPlot[1]);
def short = (fmaPlot < smaPlot) and (fmaPlot[1] >= smaPlot[1]);
AssignPriceColor(if long then Color.CYAN else if short then Color.MAGENTA else Color.CURRENT);
@samer800 thank you some much for all your help. really appreciate your work. please one last thing dont forget the scan please. Thank you in advance.add this for Candle Color
CSS:def long = (fmaPlot > smaPlot) and (fmaPlot[1] <= smaPlot[1]); def short = (fmaPlot < smaPlot) and (fmaPlot[1] >= smaPlot[1]); AssignPriceColor(if long then Color.CYAN else if short then Color.MAGENTA else Color.CURRENT);
scan not possible for this script.@samer800 thank you some much for all your help. really appreciate your work. please one last thing dont forget the scan please. Thank you in advance.
This indicator appears to be repainting. It's better or worse depending on the settings; For example if heikin is negative or if the heikin time frame setting and the charts time frame don't match. Can this be fixed?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.