Camelotnite
New member
I'm a big fan of CCI indicator. Hence I took the code and change it to a CCI indicator instead. The test results look amazing. There are some coding which I don't really understand (e.g. def CCI = 1 * (ChgRatio + 1)). Any comments will be much appreciated.
Code:
#######################start code
input length = 5;
input over_Bought = 100;
input over_Sold = -100;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def CCI = 1 * (ChgRatio + 1);
def BULL = over_Sold;
def BEAR = over_Bought;
def UpSignal = if CCI crosses above BEAR then BEAR else Double.NaN;
def DownSignal = if CCI crosses below BULL then BULL else Double.NaN;
#RSI ALERT
def Bearish = CCI crosses below 100;
def Bullish = CCI crosses above -100;
Alert(Bullish, ” CCI Possible SIGNAL UP ”, Alert.BAR, Sound.Ding);
Alert(Bearish, " CCI Possible SIGNAL DOWN ", Alert.BAR, Sound.Ding);
#For Orders
input TradeSize = 2;
def Ent = CCI(length)."CCI" crosses above -100 ;
def Ext = CCI(length)."CCI" crosses below 100 or CCI(length)."CCI" >= 85;
AddOrder(OrderType.BUY_TO_OPEN, Ent, close, TradeSize);
AddOrder(OrderType.SELL_TO_CLOSE, Ext, close, TradeSize);
#end code