[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] trying to calculate CCI for multiple timeframes



PureBytes Links

Trading Reference Links

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);




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/