Inputs:
Length(20);
Variables:
SMAValue(0),
Price(0),
BuySignal(False),
SellSignal(False);
SMAValue = Average(Close, Length);
Price = Close;
BuySignal = Price > SMAValue and Price[1] <= SMAValue;
SellSignal = Price < SMAValue and Price[1] >= SMAValue;
If BuySignal Then
Buy ("Buy Entry") Next Bar at Market
Else
If SellSignal Then
Sell ("Sell Entry") Next Bar at Market
Else
If SellSignal Then
Sell ("Sell Entry") Next Bar at Market;