Ema crossing candles

H

Happymono

New member
VIP
Tried to edit a script i found posted here to show different colors depending on the location of price around the ema's the script edited below is getting there but i can't figure out the transition colors correctly or when its between ema's





Code:
input evg1 = 50;
input evg2 = 200;
def EMA1 = ExpAverage(close[-0], evg1);
def EMA2 = ExpAverage(close[-0], evg2);

AssignPriceColor (if close > EMA2
then if open > close
then Color.cyan
else Color.cyan
else if close > EMA1
then if open > close
then Color.green
else Color.green
else if close < EMA2
then if open < close
then Color.red
else Color.red
else if close < EMA1
then if open < close
then Color.dark_ORANGE
else Color.dark_ORANGE
else color.yellow );
 
Last edited by a moderator:
BenTen

BenTen

Administrative
Staff
VIP
Is this based on another indicator from TradingView? If so, post that code as well so we can convert it for you.
 
H

Happymono

New member
VIP
Code:

Code:
//@version=3
//DEPTHHOUSE EMA CANDLESTICKS by oh92
//if you edit please drop a line :)
//
study(title="EMA Candles", shorttitle="DepthHouse EMA Candles", overlay=true)

////INPUTS////
src = input(title="Source", type=source, defval=close)
fast=input(50) //Fast EMA Band
slow=input(200) //Slow EMA Band

////EMA FORMULAS////
fe=ema(src,fast)
se=ema(src,slow)

////OH92's FAVORITE COLORS////
g = #8cffe5
r = #ff848a
gg = #adff75
rr = #ff80be
w = #ffffff

////BAR COLOR FORMULA////
bc=fe>se?crossunder(src,se)?w:src>fe?g:src>se?gg:w:crossover(src,se)?w:src<fe?r:src<se?rr:src>fe?src>se?gg:na:na

///OUTPUT///
barcolor(bc)
 
BenTen

BenTen

Administrative
Staff
VIP
@Happymono Here you go. Credit to @diazlaz

Code:
# DEPTHHOUSE EMA CANDLESTICKS by oh92
# Converted from https://www.tradingview.com/script/qcCrtv61-DepthHouse-Exponential-Candles/

input src = close;
input fast = 50;
input slow = 200;

def fe = ExpAverage(src, fast);
def se = ExpAverage(src, slow);

plot pFast = fe;
plot pSlow = se;

AssignPriceColor(
if fe > se then
if src crosses below se then color.white else
if src > fe then color.green else
if src > se then color.dark_green else
color.white else
if src crosses above se then color.white else
if src < fe then color.red else if src < se then color.dark_red else
if src > fe then if src > se then color.dark_green else color.dark_gray
else color.dark_gray
);
 

Similar threads

Top