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

[amibroker] Wrong signal with MACD



PureBytes Links

Trading Reference Links

Hi,

Can someone able to help me with this system. I try to reduce 
all "timeframeexpand" and also don't understand why this code don't 
respect the cond2 and cond4 (MACD>0 and MACD<0).

Hope you understand what i try to explain. :) 

MY CODE :

Temp = in45minute;
Mm = 20;  		

TimeFrameSet(Temp);
MA_H=MA(H,Mm);				
MA_B=MA(L,Mm);
MACDind= MACD(12,26);
MACDsign= Signal(12,26,9);
Div = MACDind - MACDsign;
TimeFrameRestore();

MACDind1= TimeFrameExpand(MACD(12,26),Temp);
MACDsign1= TimeFrameExpand(Signal(12,26,9),Temp);
Div1 = MACDind1 - MACDsign1;
MACD_1 = TimeFrameExpand(Ref(div1,-5),Temp);
MACD_2 = TimeFrameExpand(Ref(div1,-4),Temp);

BuyPrice =  TimeFrameExpand(MA_B,Temp);
SellPrice = TimeFrameExpand(MA_H,Temp);
ShortPrice = TimeFrameExpand(MA_H,Temp);
CoverPrice= TimeFrameExpand(MA_B,Temp);

Cond1 = Cross(High,TimeFrameExpand(MA_B,Temp)) OR Cross 
Low,TimeFrameExpand(MA_B,Temp));

Cond2 = MACD_1>=0 AND MACD_2>=0;

Cond3 = Cross(TimeFrameExpand(MA_H,Temp),High) OR Cross
(TimeFrameExpand(MA_H,Temp),Low);

Cond4 = MACD_1<=0 AND MACD_2<=0;

Buy = Cond1 AND Cond2;
Sell = Cond3 OR TimeNum() > 151000;
Short = Cond3 AND Cond4;
Cover = Cond1 OR TimeNum() > 151000;

_SECTION_BEGIN("SIGNAUX");
Sign_Buy = ExRem(Buy,Sell);
Sign_Sell = ExRem(Sell,Buy);
Sign_Short = ExRem(Short,Cover);
Sign_Cover= ExRem(Cover,Short);




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

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

For other support material please check also:
http://www.amibroker.com/support.html
 
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/