//Candles or bars colored by trend
//identifying trends with EMA and MACD
Period = Optimize("Period", 17, 2, 200, 1);
EMACALC = EMA(C, Period);
cond1 = Close > EMACALC AND MACD() > Signal();
cond2 = Close > EMACALC AND MACD() < Signal() OR Close < EMACALC AND MACD() > Signal();
cond3 = Close < EMACALC AND MACD() < Signal();
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetBarFillColor(IIf(Cond1,ParamColor("Candle UP Color", colorGreen),IIf(Cond3,ParamColor("Candle Down Color", colorRed),colorBlack)));
Plot(C,"\nPrice",IIf(cond1,ParamColor("Wick UP Color", colorDarkGreen),IIf(cond3,ParamColor("Wick Down Color", colorDarkRed),colorBlack)),64,0,0,0,0);
//Plot( C, "Close", ParamColor("Color", colorgreen ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
//============== TITLE ==============
_SECTION_BEGIN("Title");
Title = EncodeColor(colorGold)+ "GRAFICO BASICO" + EncodeColor(colorRose)+" (" + Name() + ") " + EncodeColor(colorGold)+ Interval(2) +
" " + Date() +" " +" • Open "+WriteVal(O,1.20)+" • "+"High "+WriteVal(H,1.20)+" • "+"Low "+WriteVal(L,1.20)+" • "+
"Close "+WriteVal(C,1.20)+" • Variação R$ = " +WriteVal(C-Ref(C,-1),1.20,0)+" • Variação % = " +WriteVal((C-Ref(C,-1))*100/Ref(C,-1),1.2)+ "% • Volume = "+ WriteVal(V,1.0);
upbar = COND1;
downbar = COND3;
/* Colourized price bars drawn here */
Graph0 = Close;
Graph0Style = 64;//number 64 = candlestick or 128 = bar;
barcolor = IIf( downbar, 4, IIf( upbar, 5, 20 ) );//number 4 = red, number 5 = green and number 42 = yellow;
Graph0BarColor = ValueWhen( barcolor != 0, barcolor );
_SECTION_END();
Plot(EMACALC, "EMACALC", colorBlack, styleLine,0,0,0,0,2);
******************************
Thanks for the above EMA !
If you find time, please confirm whether I have clearly understood the trade strategy:
Now after applying this AFL, we watch the hourly candle, if it has Closed Positive , we look for a BUY level in Gann Square of 9 after applying the closing level of the Candle in it! SL also as per Gann. Its the target that is fixed at 10 points. Just the opposite for SELL: we need a Candle closing Red (Down/Negative)!
After target is met we wait for another Candle to close and look for Gann levels as before.
If the trade as per Gann level is not triggered before the close of next candle, we apply the current candle's close to get the fresh Gann levels! The previous Gann levels are null!
If the trade is triggered and Target or SL hit, we again wait for a New hourly candle to close and trade again with new targets.
Max 5/6 trades per day should be attempted!