Market Cipher A (upper study)

The Gun Guy

New member
Code:
//@version=3
study(title="Market Cipher A", overlay=true)
//EMA Ribbon
ema1 = input(5)
ema2 = input(11)
ema3 = input(15)
ema4 = input(18)
ema5 = input(21)
ema6 = input(24)
ema7 = input(28)
ema8 = input(34)
ema1_ = ema(close, ema1)
ema2_ = ema(close, ema2)
ema3_ = ema(close, ema3)
ema4_ = ema(close, ema4)
ema5_ = ema(close, ema5)
ema6_ = ema(close, ema6)
ema7_ = ema(close, ema7)
ema8_ = ema(close, ema8)
plot(ema1_, color=#265aa6, linewidth=2, transp=50, title="EMA 1")
plot(ema2_, color=#265aa6, linewidth=2, transp=50, title="EMA 2")
plot(ema3_, color=#1976d2, linewidth=2, transp=50, title="EMA 3")
plot(ema4_, color=#1976d2, linewidth=2, transp=50, title="EMA 4")
plot(ema5_, color=#7fb3ff, linewidth=2, transp=50, title="EMA 5")
plot(ema6_, color=#7fb3ff, linewidth=2, transp=50, title="EMA 6")
plot(ema7_, color=#bbdefb, linewidth=2, transp=50, title="EMA 7")
plot(ema8_, color=#bbdefb, linewidth=2, transp=50, title="EMA 8")

Longema = crossover(ema2_,ema8_)
plotshape(Longema, style=shape.circle, color=green, transp=0, location=location.abovebar, size=size.tiny, title="Long EMA Signal")
Redcross = crossunder(ema1_,ema2_)
plotshape(Redcross, style=shape.xcross, color=red, transp=0, location=location.abovebar, size=size.tiny, title="Red cross")
Bluetriangle = crossover(ema2_,ema3_)
plotshape(Bluetriangle, style=shape.triangleup, color=blue, transp=0, location=location.belowbar, size=size.small, title="Blue Triangle")

//Alerts
alertcondition(Redcross != 0, "RedX", " RedX")
alertcondition(Longema != 0, "Longema", "Longema")
alertcondition(Bluetriangle!= 0, "Bluetriangle", " Bluetriangle")

//-------------------END-------------------
 
It's Market Cipher A ribbons from Trading view. I found Market Cipher B here, and a couple of people ask for A, but I can't seem to find it converted for ToS. I would love a version. Also, where is the best place to learn to just convert codes myself?
 

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

@The Gun Guy As you have seen there haven't been any posters interested in doing this conversion up to now. Unfortunately there is no magic code translator/converter... If you provide an image and a convincing spiel as to why this might be a great tool to add to our investing toolbox, perhaps you will generate interest in someone re-looking at this project.
https://usethinkscript.com/threads/how-to-insert-image-in-a-post-thread.277/
 
Market Cipher A is an EMA ribbon comprised of 8 EMAs that are blue/white during a bull market and gray during a bear market. ... It also gives a great visual of the trend, supplying you with strong mathematical support or resistance. Market Cipher A was made to easily analyze, isolate, and anticipate macro trends.
 
@The Gun Guy - here you go

Ruby:
# Market Cipher A
# Converted to thinkscript by bigboss
# Version 1.0 - 2021-08-05 initial version

input averageType = AverageType.EXPONENTIAL;

input ema1length = 5;
input ema1price = close;

input ema2length = 11;
input ema2price = close;

input ema3length = 15;
input ema3price = close;

input ema4length = 18;
input ema4price = close;

input ema5length = 21;
input ema5price = close;

input ema6length = 24;
input ema6price = close;

input ema7length = 28;
input ema7price = close;

input ema8length = 34;
input ema8price = close;

plot ema1 = MovingAverage(averageType, ema1price, ema1length);
plot ema2 = MovingAverage(averageType, ema2price, ema2length);
plot ema3 = MovingAverage(averageType, ema3price, ema3length);
plot ema4 = MovingAverage(averageType, ema4price, ema4length);
plot ema5 = MovingAverage(averageType, ema5price, ema5length);
plot ema6 = MovingAverage(averageType, ema6price, ema6length);
plot ema7 = MovingAverage(averageType, ema7price, ema7length);
plot ema8 = MovingAverage(averageType, ema8price, ema8length);

ema1.SetDefaultColor(CreateColor(38,90,166));
ema2.SetDefaultColor(CreateColor(38,90,166));
ema3.SetDefaultColor(CreateColor(25,118,210));
ema4.SetDefaultColor(CreateColor(25,118,210));
ema5.SetDefaultColor(CreateColor(127,179,255));
ema6.SetDefaultColor(CreateColor(127,179,255));
ema7.SetDefaultColor(CreateColor(187,222,251));
ema8.SetDefaultColor(CreateColor(187,222,251));

plot circle = if EMA2 CROSSES ABOVE EMA8 then high*1.00005 else double.nan;
circle.setpaintingStrategy(paintingStrategy.POINTS);
circle.setDefaultColor(color.green);
circle.SetlineWeight(3);

plot redCross = if ema1 crosses below ema2 then high*1.00005 else double.nan;
redCross.setPaintingStrategy(paintingStrategy.SQUARES);
redCross.SetDefaultColor(color.red);
redcross.SetlineWeight(3);

plot blueTriangle = if ema2 crosses above ema3 then low*0.99995 else double.nan;
blueTriangle.SetPaintingStrategy(paintingStrategy.TRIANGLES);
blueTriangle.SetdefaultColor(color.cyan);

Alert(!isNan(circle), "EMA 2 Cross above EMA8", Alert.BAR, Sound.NoSound);
Alert(!isNan(redCross), "EMA 1 Cross below EMA2", Alert.BAR, Sound.NoSound);
Alert(!isNan(blueTriangle), "EMA 2 Cross above EMA3", Alert.BAR, Sound.NoSound);

pour one out for all the pc's that will be crushed under the immense processing power required to draw not one, not two, not three, not four, not five, not six, not seven, but EIGHT EMA's! :-D you guys crack me up.
 
Last edited:
@The Gun Guy


pour one out for all the pc's that will be crushed under the immense processing power required to draw not one, not two, not three, not four, not five, not six, not seven, but EIGHT EMA's! :-D you guys crack me up.

@bigboss he posted a older verison mind doing the ver4? doesnt add too much, but it is a little better imo

9hWqVcG9


Cipher Version 4


@The Gun Guy do you have version b? I found one here but its not exactly the same, ranges are off.
 
@thePunkville I don't code, but glancing at your pic of version 4 and comparing it to what I've seen of BigBoss' code. It seems like the only thing missing is the ema cloud. If that is what you want, below is the code. I got it from a guy on twitter named Ripster. No idea where he got it from.
Code:
input price = close;#hint price: The price used to calculate the crossover. <b>(Default is CLOSE)</b>
input fastLength = 8;#hint fastLength: The number of bars used to calculate the fast moving average. <b>(Default is 3)</b>
input slowLength = 21;#hint slowLength: The number of bars used to calculate the slow moving average. <b>(Default is 8)</b>
input slowAvgType = {default Simple, Exponential, Weighted, Wilders, Hull};#hint slowAvgType: Type of the fast moving average to be used for calculation. <b>(Default is Expontential)</b>
input fastAvgType = {default Simple, Exponential, Weighted, Wilders, Hull};#hint fastAvgType: Type of the fast moving average to be used for calculation. <b>(Default is Exponential)</b>
Input DoArrows = no;#hint DoArrows:Yes shows arrows to define crosses
Input DoPlots = yes;#hint DoPlots: Yes shows MA plots to define crosses. Default is 'YES'
Input DoAlerts = No;#hint DoAlerts:No turns off alerts
Assert( fastLength < slowLength, "fastLength ["+fastLength+"] must be less than slowLength["+slowLength+"]");

def fastAvg;
switch (slowAvgType) {
case Simple:
    fastAvg = Average(price, fastLength);
case Exponential:
    fastAvg = ExpAverage(price, fastLength);
case Weighted:
    fastAvg = wma(price, fastLength);
case Wilders:
    fastAvg = WildersAverage(price, fastLength);
case Hull:
    fastAvg = HullMovingAvg(price, fastLength);
}

def slowAvg;
switch (fastAvgType) {
case Simple:
    slowAvg = Average(price, slowLength);
case Exponential:
    slowAvg = ExpAverage(price, slowLength);
case Weighted:
    slowAvg = wma(price, slowLength);
case Wilders:
    slowAvg = WildersAverage(price, slowLength);
case Hull:
    slowAvg = HullMovingAvg(price, slowLength);
}

plot signalXup = If DoArrows Then crosses(fastAvg, slowAvg, CrossingDirection.above) else Double.nan;
signalXup.SetDefaultColor(Color.pink);
signalXup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signalXup.SetLineWeight(3);

plot signalXdn =  If DoArrows Then crosses(fastAvg, slowAvg, CrossingDirection.below) else Double.nan;
signalXdn.SetDefaultColor(Color.Green);
signalXdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signalXdn.SetLineWeight(3);


Plot fast_Avg = If DoPlots  then Fastavg else double.nan;
fast_Avg.SetDefaultColor(Color.pink);
fast_Avg.SetPaintingStrategy(PaintingStrategy.line);
fast_Avg.SetLineWeight(2);
Plot Slo_Avg = If DoPlots  then Slowavg else double.nan;
Slo_Avg.SetDefaultColor(Color.cyan);
Slo_Avg.SetPaintingStrategy(PaintingStrategy.line);
Slo_Avg.SetLineWeight(2);
AddCloud(fastAvg, slowAvg, color.cyan, color.pink);
#AddLabel(1, "Fast MA(" + fastLength + ")",color.pink);
#AddLabel(1, "Slow MA(" + slowLength + ")",color.cyan);

#Trigger alerts
#alert(Fastavg, "CHECK IT OUT", Alert.Bar, Sound.Ding);
 
@The Gun Guy - here you go

Ruby:
# Market Cipher A
# Converted to thinkscript by bigboss
# Version 1.0 - 2021-08-05 initial version

input averageType = AverageType.EXPONENTIAL;

input ema1length = 5;
input ema1price = close;

input ema2length = 11;
input ema2price = close;

input ema3length = 15;
input ema3price = close;

input ema4length = 18;
input ema4price = close;

input ema5length = 21;
input ema5price = close;

input ema6length = 24;
input ema6price = close;

input ema7length = 28;
input ema7price = close;

input ema8length = 34;
input ema8price = close;

plot ema1 = MovingAverage(averageType, ema1price, ema1length);
plot ema2 = MovingAverage(averageType, ema2price, ema2length);
plot ema3 = MovingAverage(averageType, ema3price, ema3length);
plot ema4 = MovingAverage(averageType, ema4price, ema4length);
plot ema5 = MovingAverage(averageType, ema5price, ema5length);
plot ema6 = MovingAverage(averageType, ema6price, ema6length);
plot ema7 = MovingAverage(averageType, ema7price, ema7length);
plot ema8 = MovingAverage(averageType, ema8price, ema8length);

ema1.SetDefaultColor(CreateColor(38,90,166));
ema2.SetDefaultColor(CreateColor(38,90,166));
ema3.SetDefaultColor(CreateColor(25,118,210));
ema4.SetDefaultColor(CreateColor(25,118,210));
ema5.SetDefaultColor(CreateColor(127,179,255));
ema6.SetDefaultColor(CreateColor(127,179,255));
ema7.SetDefaultColor(CreateColor(187,222,251));
ema8.SetDefaultColor(CreateColor(187,222,251));

plot circle = if EMA2 CROSSES ABOVE EMA8 then high*1.00005 else double.nan;
circle.setpaintingStrategy(paintingStrategy.POINTS);
circle.setDefaultColor(color.green);
circle.SetlineWeight(3);

plot redCross = if ema1 crosses below ema2 then high*1.00005 else double.nan;
redCross.setPaintingStrategy(paintingStrategy.SQUARES);
redCross.SetDefaultColor(color.red);
redcross.SetlineWeight(3);

plot blueTriangle = if ema2 crosses above ema3 then low*0.99995 else double.nan;
blueTriangle.SetPaintingStrategy(paintingStrategy.TRIANGLES);
blueTriangle.SetdefaultColor(color.cyan);

Alert(!isNan(circle), "EMA 2 Cross above EMA8", Alert.BAR, Sound.NoSound);
Alert(!isNan(redCross), "EMA 1 Cross below EMA2", Alert.BAR, Sound.NoSound);
Alert(!isNan(blueTriangle), "EMA 2 Cross above EMA3", Alert.BAR, Sound.NoSound);

pour one out for all the pc's that will be crushed under the immense processing power required to draw not one, not two, not three, not four, not five, not six, not seven, but EIGHT EMA's! :-D you guys crack me up.
This code works on all time frame that is Day or lower, but it doesn't work on Weekly or Monthly. Anyone know why?
 
It works on weekly and monthly for me. I used AAPL as a test.
I tested it again,
SPX - Does not work on Yearly
AAPL - Does not work on quarterly and above
TSLA - Does not work on monthly and above
HOOD - Does not work on 1hr and above

So take SPX for example, TOS data goes back to 1928. The built in (default) moving average will go more or less all the way back on the Quarter time frame. Your script will stop at 1977, even though I can keep scrolling all the way back to 1928.

BTW I changed your script from exponential to simple, but I "assume" that shouldn't matter. Below is your code that I edited.

Code:
# Market Cipher A
# Converted to thinkscript by bigboss
# Version 1.0 - 2021-08-05 initial version
# Edited by petech - changed from exponential to simple 

input averageType = AverageType.SIMPLE;

input sma3length = 3;
input sma3price = close;

input sma9length = 9;
input sma9price = close;

input sma20length = 20;
input sma20price = close;

input sma30length = 30;
input sma30price = close;

input sma50length = 50;
input sma50price = close;

input sma100length = 100;
input sma100price = close;

input sma200length = 200;
input sma200price = close;

plot sma3 = MovingAverage(averageType, sma3price, sma3length);
plot sma9 = MovingAverage(averageType, sma9price, sma9length);
plot sma20 = MovingAverage(averageType, sma20price, sma20length);
plot sma30 = MovingAverage(averageType, sma30price, sma30length);
plot sma50 = MovingAverage(averageType, sma50price, sma50length);
plot sma100 = MovingAverage(averageType, sma100price, sma100length);
plot sma200 = MovingAverage(averageType, sma200price, sma200length);

sma3.SetDefaultColor(CreateColor(255,165,0));
sma9.SetDefaultColor(CreateColor(255,0,0));
sma20.SetDefaultColor(CreateColor(25,118,210));
sma30.SetDefaultColor(CreateColor(255,255,0));
sma50.SetDefaultColor(CreateColor(0,128,0));
sma100.SetDefaultColor(CreateColor(149,85,0));
sma200.SetDefaultColor(CreateColor(234,136,255));


#plot blueTriangle = if sma3 CROSSES ABOVE sma9 then high*1.00005 else double.nan;
#blueTriangle.setpaintingStrategy(paintingStrategy.triangles);
#blueTriangle.setDefaultColor(CreateColor(0,255,255));
#blueTriangle.SetlineWeight(3);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
330 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