does anyone has already converted this Daily weekly MACD crossover ?
https://www.tradingview.com/v/jXGtme2P/
https://www.tradingview.com/v/jXGtme2P/
Last edited by a moderator:
find belowdoes anyone has already converted this Daily weekly MACD crossover ?
https://www.tradingview.com/v/jXGtme2P/
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L1 Vitali Apirine Weekly And Daily MACD", overlay=false,
# Converted by Sam4Cok@Samer800 - 07/2023
declare lower;
#// TASC DEC 2017
#// Weekly And Daily MACD
#// Vitali Apirine
#//inputs:
input DailyFastLength = 12; # "DailyFastLength"
input DailySlowLength = 26; # "DailySlowLength"
input WeeklyFastLength = 60; # "WeeklyFastLength"
input WeeklySlowLength = 130; # "WeeklySlowLength"
input SigLength = 9; # "SigLength"
def na = Double.NaN;
def last = isNaN(close);
DefineGlobalColor("upInc", CreateColor(255,82,82));
DefineGlobalColor("upDec", CreateColor(33,150,243));
DefineGlobalColor("dnInc", CreateColor(0,230,118));
DefineGlobalColor("dnDec", CreateColor(255,235,59));
script f_macd {
input src = close;
input fast = 12;
input slow = 26;
input SigLength = 9;
def fastMA = ExpAverage(src, fast);
def slowMA = ExpAverage(src, slow);
def mac = fastMA - slowMA;
def sig = ExpAverage(mac, SigLength);
def his = mac - sig;
plot hist = his;
}
#//algo:
def DailyMACD = f_macd( close, DailyFastLength, DailySlowLength, SigLength );
def WeeklyMACD = f_macd( close, WeeklyFastLength, WeeklySlowLength,SigLength );
def RelativeDailyLine = WeeklyMACD + DailyMACD;
def Plot1 = WeeklyMACD; # "Weekly MACD"
def Plot2 = RelativeDailyLine;#, "Relative MACD"
plot Plot3 = if last then na else 0;#, "Zero Line" )
Plot3.SetDefaultColor(Color.GRAY);
AddCloud(Plot2, Plot1, Color.GREEN, Color.RED);
#/define MACD histogram
def dif = ( RelativeDailyLine -WeeklyMACD );
def ghist = dif / 2;
def pos_ghist = max(0, ghist);
def neg_ghist = min(0, ghist);
def currhist = ghist[0];
def prevhist = ghist[1];
def plotColor = if ghist > 0 then
if currhist > prevhist then 2 else 1 else
if currhist < prevhist then -2 else -1;
#//plot MACD histogram
plot HistUp = pos_ghist;
plot HistDn = neg_ghist;
plot Signal = ghist;
HistUp.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
HistDn.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Signal.SetLineWeight(2);
Signal.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else
if plotColor== 1 then GlobalColor("upDec") else
if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec"));
HistUp.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else
if plotColor== 1 then GlobalColor("upDec") else
if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec"));
HistDn.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else
if plotColor== 1 then GlobalColor("upDec") else
if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec"));
#-- END of CODE
It's available in TOS platform as "WeeklyAndDailyMACD".does anyone has already converted this Daily weekly MACD crossover ?
https://www.tradingview.com/v/jXGtme2P/
you have been so much helpfull.thank you so much sam..is it possible to convert to MTF ?find below
CSS:#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ #// © blackcat1402 #study("[blackcat] L1 Vitali Apirine Weekly And Daily MACD", overlay=false, # Converted by Sam4Cok@Samer800 - 07/2023 declare lower; #// TASC DEC 2017 #// Weekly And Daily MACD #// Vitali Apirine #//inputs: input DailyFastLength = 12; # "DailyFastLength" input DailySlowLength = 26; # "DailySlowLength" input WeeklyFastLength = 60; # "WeeklyFastLength" input WeeklySlowLength = 130; # "WeeklySlowLength" input SigLength = 9; # "SigLength" def na = Double.NaN; def last = isNaN(close); DefineGlobalColor("upInc", CreateColor(255,82,82)); DefineGlobalColor("upDec", CreateColor(33,150,243)); DefineGlobalColor("dnInc", CreateColor(0,230,118)); DefineGlobalColor("dnDec", CreateColor(255,235,59)); script f_macd { input src = close; input fast = 12; input slow = 26; input SigLength = 9; def fastMA = ExpAverage(src, fast); def slowMA = ExpAverage(src, slow); def mac = fastMA - slowMA; def sig = ExpAverage(mac, SigLength); def his = mac - sig; plot hist = his; } #//algo: def DailyMACD = f_macd( close, DailyFastLength, DailySlowLength, SigLength ); def WeeklyMACD = f_macd( close, WeeklyFastLength, WeeklySlowLength,SigLength ); def RelativeDailyLine = WeeklyMACD + DailyMACD; def Plot1 = WeeklyMACD; # "Weekly MACD" def Plot2 = RelativeDailyLine;#, "Relative MACD" plot Plot3 = if last then na else 0;#, "Zero Line" ) Plot3.SetDefaultColor(Color.GRAY); AddCloud(Plot2, Plot1, Color.GREEN, Color.RED); #/define MACD histogram def dif = ( RelativeDailyLine -WeeklyMACD ); def ghist = dif / 2; def pos_ghist = max(0, ghist); def neg_ghist = min(0, ghist); def currhist = ghist[0]; def prevhist = ghist[1]; def plotColor = if ghist > 0 then if currhist > prevhist then 2 else 1 else if currhist < prevhist then -2 else -1; #//plot MACD histogram plot HistUp = pos_ghist; plot HistDn = neg_ghist; plot Signal = ghist; HistUp.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM); HistDn.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM); Signal.SetLineWeight(2); Signal.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else if plotColor== 1 then GlobalColor("upDec") else if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec")); HistUp.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else if plotColor== 1 then GlobalColor("upDec") else if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec")); HistDn.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else if plotColor== 1 then GlobalColor("upDec") else if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec")); #-- END of CODE
check belowyou have been so much helpfull.thank you so much sam..is it possible to convert to MTF ?
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L1 Vitali Apirine Weekly And Daily MACD", overlay=false,
# Converted by Sam4Cok@Samer800 - 07/2023
# Update - MTF option added.
declare lower;
#// TASC DEC 2017
#// Weekly And Daily MACD
#// Vitali Apirine
#//inputs:
input useChartTimeframe = {Default "Yes", "No"};
input manualTimeframe = AggregationPeriod.FIFTEEN_MIN;
input DailyFastLength = 12; # "DailyFastLength"
input DailySlowLength = 26; # "DailySlowLength"
input WeeklyFastLength = 60; # "WeeklyFastLength"
input WeeklySlowLength = 130; # "WeeklySlowLength"
input SigLength = 9; # "SigLength"
def na = Double.NaN;
def last = isNaN(close);
DefineGlobalColor("upInc", CreateColor(255,82,82));
DefineGlobalColor("upDec", CreateColor(33,150,243));
DefineGlobalColor("dnInc", CreateColor(0,230,118));
DefineGlobalColor("dnDec", CreateColor(255,235,59));
def mtf;
Switch (useChartTimeframe) {
Case "Yes" : mtf = close;
Case "No" : mtf = close(Period=manualTimeframe);
}
script f_macd {
input src = close;
input fast = 12;
input slow = 26;
input SigLength = 9;
def fastMA = ExpAverage(src, fast);
def slowMA = ExpAverage(src, slow);
def mac = fastMA - slowMA;
def sig = ExpAverage(mac, SigLength);
def his = mac - sig;
plot hist = his;
}
#//algo:
def DailyMACD = f_macd( mtf, DailyFastLength, DailySlowLength, SigLength );
def WeeklyMACD = f_macd( mtf, WeeklyFastLength, WeeklySlowLength,SigLength );
def RelativeDailyLine = WeeklyMACD + DailyMACD;
def upcolor = RelativeDailyLine>=WeeklyMACD;
def Daily = RelativeDailyLine;#, "Relative MACD"
def Weekly = WeeklyMACD; # "Weekly MACD"
plot Zero = if last then na else 0;#, "Zero Line" )
Zero.SetDefaultColor(Color.GRAY);
AddCloud(Daily, Weekly, Color.GREEN, Color.RED);
#/define MACD histogram
def dif = ( RelativeDailyLine -WeeklyMACD );
def ghist = dif / 2;
def pos_ghist = max(0, ghist);
def neg_ghist = min(0, ghist);
def currhist = ghist[0];
def prevhist = ghist[1];
def plotColor = if ghist > 0 then
if currhist > prevhist then 2 else 1 else
if currhist < prevhist then -2 else -1;
#//plot MACD histogram
plot HistUp = pos_ghist;
plot HistDn = neg_ghist;
plot Signal = ghist;
HistUp.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
HistDn.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Signal.SetLineWeight(2);
Signal.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else
if plotColor== 1 then GlobalColor("upDec") else
if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec"));
HistUp.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else
if plotColor== 1 then GlobalColor("upDec") else
if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec"));
HistDn.AssignValueColor(if plotColor== 2 then GlobalColor("upInc") else
if plotColor== 1 then GlobalColor("upDec") else
if plotColor==-2 then GlobalColor("dnInc") else GlobalColor("dnDec"));
#-- END of CODE
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.