I'm trying to calculate a buy/sell signal for CCI crosses above -100 and below
100 in multiple time frames (1,30,60 minute), while looking at a chart in 1
minute intervals. THe sample code below does not seem to get any results in my
screens. Am I using TimeFrameSet() correctly? I am getting the CCI for 30
min, 60 min, then 1 min. Then I try to see if cci30 and cci60 are below -100
or above 100 and also try to get a cross of the 1 minute bar at the same time.
But I don't get anything...I changed the code to just use the 1 min and 60 and
still don't get anyting...I know that for SPY over the past few months, the 60
min CCI has been above/below the overbought/oversold level while the 1 min does
the cross above below the level...what am I doing wrong?
Here is the CODE:
Count = 0;
result = 0;
periods = Param( "Periods", 14, 2, 200, 1 );
TimeFrameSet( 30 * in1Minute );
myCCI=CCI( periods );
BuyCCI_30=myCCI < -100;
SellCCI_30=myCCI > 100;
printf("cci30=%.2f, buy=%.2f, sell=%.2f, price=%.2f\n", myCCI, BuyCCI_30,
SellCCI_30, Close);
TimeFrameRestore();
TimeFrameSet( 60 * in1Minute );
myCCI=CCI( periods );
BuyCCI_60=myCCI < -100;
SellCCI_60=myCCI > 100;
printf("cci60=%.2f, buy=%.2f, sell=%.2f, price=%.2f\n", myCCI, BuyCCI_60,
SellCCI_60, Close);
TimeFrameRestore();
TimeFrameSet( 1 * in1Minute );
myCCI=CCI( periods );
BuyCCI_1=Cross(myCCI, -100);
SellCCI_1=Cross(100, myCCI);
printf("cci1 =%.2f, buy=%.2f, sell=%.2f, price=%.2f\n", myCCI, BuyCCI_1,
SellCCI_1, Close);
TimeFrameRestore();
Buy=BuyCCI_1 AND BuyCCI_30;
Sell=SellCCI_1 AND SellCCI_30;
//Buy=BuyCCI_1 AND BuyCCI_30 AND BuyCCI_60;
//Sell=SellCCI_1 AND SellCCI_30 AND BuyCCI_60;
// trade on next bar open
SetTradeDelays( 1, 1, 1, 1 );
BuyPrice = SellPrice = Open;
Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);
Short=Sell;Cover=Buy;
Short=ExRem(Short,Cover);Cover=ExRem(Cover,Short);