Colore Candles Completo Bem Colorido

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

//SCRIPT para colorir os candles no TRYD//

//Colore Joselito, inside, martelo, estrela cadente, engolfo e grávida//


//Autor: Fábio Campinho//
//Data: 2018-07-25//

def barras = BARS();


r = newLines();
r.add(barras);

def itens = barras.size();

for (int index = 1; index < itens; index++ ) {


//Variaveis de apoio
def aBar = index == 1 ? barras.bar(index - 1) : barras.bar(index - 2);
def pBar = barras.bar(index - 1);
def bar = barras.bar(index);

def aHigh = aBar.getHigh();


def aLow = aBar.getLow();
def pHigh = pBar.getHigh();
def pLow = pBar.getLow();
def cLow = bar.getLow();
def cHigh = bar.getHigh();

def pOpen = pBar.getOpen();


def pClose = pBar.getClose();
def pMin = pOpen > pClose ? pClose : pOpen;
def pMax = pOpen < pClose ? pClose : pOpen;

def cOpen = bar.getOpen();


def cClose = bar.getClose();
def cMin = cOpen > cClose ? cClose : cOpen;
def cMax = cOpen < cClose ? cClose : cOpen;

def aOpen = aBar.getOpen();


def aClose = aBar.getClose();
def aMin = aOpen > aClose ? aClose : aOpen;
def aMax = aOpen < aClose ? aClose : aOpen;

//Cores básicas, altere aqui as cores do candle


if (cOpen > cClose) {
bar.setFill(255, 0, 0);
bar.setBorder(255, 0, 0);
} else {
bar.setFill(0, 255, 0);
bar.setBorder(0, 255, 0);
}

//Joselito
def candleSize = cHigh - cLow;
def diffBase = candleSize * 0.25;
def bCorpo = ((cMax <= cHigh - diffBase) && (cMin >= cLow + diffBase) &&
(cMax - cMin >= 5));

// Joselito no Topo
if ((cLow > pLow && cHigh > pHigh) && bCorpo) {
if (cOpen > cClose) {
bar.setFill(0, 128, 255);
bar.setBorder(0, 128, 255);
} else {
bar.setFill(0, 128, 192);
bar.setBorder(0, 128, 192);
}
}
if ((cHigh >= pHigh) && (aLow <= pLow && aHigh <= pHigh) && !(aMax < pMax &&
aMin > pMin) || (pHigh > cHigh && pLow < cLow && index < itens - 1)) {
if (pOpen > pClose) {
pBar.setFill(255, 0, 0);
pBar.setBorder(255, 0, 0);
} else {
pBar.setFill(0, 255, 0);
pBar.setBorder(0, 255, 0);
}
}

// Joselito no Fundo, altere aqui as cores do joselito


if ((cLow < pLow && cHigh < pHigh) && bCorpo) {
if (cOpen > cClose) {
bar.setFill(0, 128, 255);
bar.setBorder(0, 128, 255);
} else {
bar.setFill(0, 128, 192);
bar.setBorder(0, 128, 192);
}
}
if ((cLow <= pLow) && (aLow >= pLow && aHigh >= pHigh) && !(aMax < pMax &&
aMin > pMin) || (pHigh > cHigh && pLow < cLow && index < itens - 1)) {
if (pOpen > pClose) {
pBar.setFill(255, 0, 0);
pBar.setBorder(255, 0, 0);
} else {
pBar.setFill(0, 255, 0);
pBar.setBorder(0, 255, 0);
}
}

//Martelo
def mBase = candleSize * 0.4;
if (cMin >= cHigh - mBase && cMax >= cHigh - 20) {
if (cOpen > cClose) {
bar.setFill(128, 128, 128);
bar.setBorder(128, 128, 128);
} else {
bar.setFill(192, 192, 192);
bar.setBorder(192, 192, 192);
}
}

//Estrela Cadente
if (cMax <= cLow + mBase && cMin <= cLow + 20) {
if (cOpen > cClose) {
bar.setFill(128, 128, 128);
bar.setBorder(128, 128, 128);
} else {
bar.setFill(192, 192, 192);
bar.setBorder(192, 192, 192);
}
}
//inside
if (pHigh > cHigh && pLow < cLow) {
if (cOpen > cClose) {
bar.setFill(255, 255, 128);
bar.setBorder(255, 255, 128);
} else {
bar.setFill(255, 255, 0);
bar.setBorder(255, 255, 0);
}
}

//Engolfo
if (pMax < cMax && pMin > cMin) {
if (cOpen > cClose) {
bar.setFill(255, 128, 0);
bar.setBorder(255, 128, 0);
} else {
bar.setFill(255, 128, 64);
bar.setBorder(255, 128, 64);
}
}

//Gravida
if (pMax > cHigh && pMin < cLow) {
if (cOpen > cClose) {
bar.setFill(255, 128, 0);
bar.setBorder(255, 128, 0);
} else {
bar.setFill(255, 128, 64);
bar.setBorder(255, 128, 64);
}
}
}

You might also like