HTML:
For Buy
Price > 5 SMA
Stochastic(5,3,3) Bullish crossover
CCI>100
All above conditions to be satisfied for a buy.
For Sell
Price <5 SMA
Stochastic (5,3,3)Bearish crossover
CCI<-100
All above conditions to be satisfied for a sell.
(Only change was CCI value rest all perfect)
Code:
//SMA
periods = Param("SMA period", 5, 2, 100, 1 );
myMA=MA(C,periods);
//Stochastics
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
myStochD=StochD( periods , Ksmooth, DSmooth );
myStochK=StochK( periods , Ksmooth);
// CCI
periods = Param("CCI period", 20, 2, 100, 1 );
myCCI = CCI( periods );
// signal conditions
BuyStoc = Cross(myStochK, myStochD );
SellStoc = Cross( myStochD, myStochK );
Buy = Cross(C,myMA) AND BuyStoc AND myCCI >100;
Sell = Cross(myMA,C) AND SellStoc AND myCCI <-100;
Buy =ExRem(Buy, Sell); // this removes additional signals between the first buy up to the
Sell = ExRem(Sell,Buy);
// explore variables
Filter = Buy OR Sell;
AddColumn(Close, "Close", 1.2);
AddColumn(Buy, "Buy", 1.0);
AddColumn(Sell, "Sell",1.0);
_SECTION_END();