// Downloaded From https://www.WiseStockTrader.com
Title = EncodeColor(colorYellow)+"    THFL. Y THIEN DO LONG KIEN " + " - " + EncodeColor(colorLavender)+ Name()+ " - "  + EncodeColor(colorLavender)+ Interval(2) + EncodeColor(colorLavender) +
 "  - " + Date() +"\n" +EncodeColor(colorLavender) +"    O-"+O+"  "+"H-"+H+"  "+"L-"+L+"  "+
"C-"+C+"  "+ "Vol = "+ WriteVal(V,1.0);
_SECTION_END();

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("PRICE");
// simple trading system
SetBarFillColor( IIf( C > O, ColorRGB( 0, 83, 0 ), IIf( C <= O, ColorRGB( 83, 0, 0 ), colorLightGrey ) ) );
Plot(C, "", IIf(O>=C, ColorRGB( 255, 0, 0 ), ColorRGB( 0, 255, 0 )), ParamStyle("Price Style", styleCandle,maskPrice));
_SECTION_END(); 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN(""); 

P = ParamField("Price field",-1);
Pema17 = Param("Pema17", 17, 2, 300, 1, 0 );
Plot( EMA( P, Pema17 ), "EMA17",colorYellow , ParamStyle("Style", styleLine|styleThick, maskDefault| styleThick) );

Pema50 = Param("Pema50", 50, 2, 300, 1, 0 );
Plot( EMA( P, Pema50 ), "EMA50",colorCustom11 , ParamStyle("Style", styleThick ) );

Pema65 = Param("Pema65", 65, 2, 300, 1, 0 );
Plot( EMA( P, Pema65 ), "EMA65",colorCustom12, ParamStyle("Style", styleThick ) );

Fs=Param("EmaYellow", 17, 2, 300, 1, 0 );
Sl=Param("EmaCyan", 50, 2, 300, 1, 0 );
Sll=Param("EmaPurple", 65, 2, 300, 1, 0 );
Ema17 = EMA(C,Fs);
Ema50 = EMA(C,Sl);
Ema65 = EMA(C,Sll);

exitshort1=Cross(Ema17,Ema50);
exitshort2=Cross(Ema17,Ema65);

exitlong1=Cross(Ema50,Ema17);
exitlong2=Cross(Ema65,Ema17);

//Buy = exitshort1;
//Buy = exitshort2;

//Sell = exitlong1;
//Sell = exitlong2;

Buy = ExRem(exitshort1,exitlong1);
Buy = ExRem(exitshort2,exitlong2);

PlotShapes(shapeUpArrow*exitshort1, colorCustom11, 0, L, -10 );
PlotShapes(shapeUpArrow*exitshort2, colorCustom12, 0, L, -15 );

//PlotShapes(shapeDownArrow*exitlong1, colorCustom11, 0, H, -10 );
//PlotShapes(shapeDownArrow*exitlong2, colorCustom12, 0, H, -15 );

_SECTION_END(); 

//

_SECTION_BEGIN("");
 
P = ParamField("Price field",-1);
Pma20 = Param("MaYellow", 20, 2, 300, 1, 0 );
Plot( MA( P, Pma20 ), "MA20",colorGold , ParamStyle("Style", styleLine|styleThick) );

Pma50 = Param("MaCyan", 50, 2, 300, 1, 0 );
Plot( MA( P, Pma50 ), "MA50",colorSkyblue , ParamStyle("Style", styleLine|styleThick ) );

Pma65 = Param("MaPurple", 65, 2, 300, 1, 0 );
Plot( MA( P, Pma65 ), "MA65",colorCustom13, ParamStyle("Style", styleLine|styleThick ) );

Fs=Param("MaYellow", 20, 2, 300, 1, 0 );
Sl=Param("MaCyan", 50, 2, 300, 1, 0 );
Sll=Param("MaPurple", 65, 2, 300, 1, 0 );
Ma20 = MA(C,Fs);
Ma50 = MA(C,Sl);
Ma65 = MA(C,Sll);

exitshort1=Cross(Ma20,Ma50);
exitshort2=Cross(Ma20,Ma65);

exitlong1=Cross(Ma50,Ma20);
exitlong2=Cross(Ma65,Ma20);

Buy  = ExRem(exitshort1,exitlong1);
Buy  = ExRem(exitshort2,exitlong2);

PlotShapes(shapeUpArrow*exitshort1, colorSkyblue, 0, L, -20 );
PlotShapes(shapeUpArrow*exitshort2, colorCustom13, 0, L, -25 );
//PlotShapes(shapeDownArrow*Sellma50, colorSkyblue, 0, H, -20 );
//PlotShapes(shapeDownArrow*Sellma65, colorCustom13, 0, H, -25 );

_SECTION_END();