// Downloaded From https://www.WiseStockTrader.com
SmaPeriodFast = 10;
SmaPeriodSlow = 30;
StartTime = 1 ; // 10000 * Hour + 100 * Minute + Second, so 12:37:15 becomes 123715
EndTime = 22;

tn = TimeNum();
timeCheck = tn >=( StartTime * 10000) AND tn <=  ( EndTime * 10000);


FastMA = MA(Close, SmaPeriodFast );
SlowMA = MA(Close, SmaPeriodSlow );

IsLong = FastMA > SlowMA;
IsShort = SlowMA > FastMA;
LongSignal  = Cross(FastMA, SlowMA);
ShortSignal = Cross(SlowMA, FastMA);


LongConfirmPrice = ValueWhen(LongSignal, H) + 0.001;
ShortConfirmPrice = ValueWhen(ShortSignal, L) - 0.001;

Buy = IsLong  AND H > LongConfirmPrice AND timeCheck ;
Sell = (IsShort AND L < ShortConfirmPrice) OR Cross( tn, EndTime);

Short = (IsShort AND L < ShortConfirmPrice) AND timeCheck ;
Cover = ( IsLong  AND H > LongConfirmPrice) OR Cross( tn, EndTime);

Buy =ExRem(Buy,Sell);
Sell =ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover= ExRem(Cover,Short);

Plot(C,"Close", colorBlack, styleCandle);
Plot(FastMA,"Fast MA", colorRed, styleThick);
Plot(SlowMA,"Slow MA", colorBlue, styleThick );

PlotShapes( IIf( LongSignal  , shapeSmallCircle + shapePositionAbove, shapeNone ), colorGreen );
PlotShapes( IIf( ShortSignal , shapeSmallCircle , shapeNone ), colorRed );

PlotShapes( IIf( Buy  , shapeUpArrow, shapeNone ), colorGreen );
PlotShapes( IIf( Sell , shapeDownArrow, shapeNone ), colorRed );