Hello everyone, love the site, have learned so much, thank you.
I am looking for some help.
simple trading plan I have but want to see it better on the chart so I can also go back and see what I missed and what I did right.
I trade long and short based on candle bouncing off the 13, 48 and 200 ema.
I am looking for the candle to change color every time it closes above and below the 13, 48 and 200 EMA, lets say the color blue.
all the rest of the time the candle holds its original color.
I have it now when the ema crosses but that is delayed so doesn't work great so im looking for when the candle closes after it crosses up or down those Emma's.
I trade on 2 minute time frame and really only day trade AMD.
@merc2226 Something like this? It's not my code, I just had it in my studies from this site. I don't remember where I got it from. I hope you find it useful.
input price = close;#hint price: The price used to calculate the crossover. <b>(Default is CLOSE)</b>
input fastLength = 13;#hint fastLength: The number of bars used to calculate the fast moving average. <b>(Default is 3)</b>
input slowLength = 200;#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.BLUE, color.DARK_orange );
#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);
AssignPriceColor(if close > FastAVG then color.green else color.red);