PureBytes Links
Trading Reference Links
|
Hi progster,
Thank you for your response. I've tried it and it still does the same thing. I should add that the printed variables are incorrect themselves [not only in relation with the arrows].
An example:
sys5_bug
Date: 7/24/2008 10:57:00 PM
PBuy_= 0 PSell_= 1
PShort_ = 0 PCover_= 0
nBuy_= 0 nSell_= 0
nShort_ = 0 nCover_= 0
inBuy = 1 inShort = 0
Branch= 3
Next bar:
sys5_bug
Date: 7/24/2008 10:58:00 PM
PBuy_= 0 PSell_= 1
PShort_ = 1 PCover_= 0
nBuy_= 0 nSell_= 0
nShort_ = 1 nCover_= 0
inBuy = 0 inShort = 1
Branch= 10
at 10:57, Branch 3 does not modify inBuy, which was 1; how did it become 0 at 10:58?
Incidentally, at 10:58, nShort_ is 1, but the triangle shape is not shown.
Thank you,
Alex
Here's the code exhibiting the bug, simplified further:
SetBarsRequired( -1, -1 );
OptimizerSetEngine("cmae");
Med = (High+Low)/2; stopLine = EMA(Med,5);
ml = MACD(12, 26); sl = Signal(12,26,9); macd_h = ml-sl;
rstopline = Ref(stopLine, -1);
rmacd_h=Ref(macd_h,-1);
Hoc = Max(O,C); Loc = Min(O,C); rC = Ref(C,-1); rH = Ref(H,-1); rL = Ref(L,-1);
stopin = rH>=rstopLine && rstopLine >=rL;
Buy_=rmacd_h>0 && rC > rstopLine && !stopin && stopline > rstopline && rmacd_h < macd_h ;
Sell_= (L < rstopLine);
Short_=rmacd_h<0 && rC < rstopLine && !stopin && stopline < rstopline && rmacd_h > macd_h;
Cover_=(H > rstopLine);
//just for debug
pBuy = Buy_; pSell = Sell_; pShort = Short_; pCover = Cover_;
printf("PBuy_= %g PSell_= %g\n", PBuy, PSell);
printf("PShort_ = %g PCover_= %g\n", PShort, PCover);
//filter the raw signals
nBuy_ = nSell_ = nShort_ = nCover_ = 0; // make sure all arrays are set empty
tRange = 0.0010; //modify this for stocks
inBuy = inShort = 0;
vinBuy = vinShort = 0;
eprice = 0; //
veprice = 0; //
branch = 0;
for( i = 0; i < BarCount; i++ )
{ //these are just for tracing
// veprice[i] = eprice; VInBuy[i] = inBuy; VInShort[i] = inShort;
branch[i] = 0;
if (inBuy == 1){
branch[i] = 1;
nbuy_[i] = 0; nshort_[i] = 0; ncover_[i] = 0;
if (sell_[i]){
branch[i] = 2;
if (C[i] > (eprice - tRange) && C[i] < (eprice + tRange)) {
branch[i] = 3;
nsell_[i] = 0;
} else {
branch[i] = 4;
nsell_[i] = 1;
inBuy = 0;
}
}
} else { //inBuy == 0
if (inShort == 1){
branch[i] = 5;
nbuy_[i] = 0; nsell_[i] = 0; nshort_[i] = 0;
if (cover_[i]){
if (C[i] > (eprice - tRange) && C[i] < (eprice + tRange)) {
branch[i] = 6;
ncover_[i] = 0;
} else {
branch[i] = 7;
ncover_[i] = 1;
inShort = 0;
}
}
} else {
branch[i] = 8;
if (buy_[i] == 1) {
branch[i] = 9;
nbuy_[i] = 1;
eprice = C[i];
inBuy = 1;
ncover_[i] = 0; nshort_[i] = 0; nSell_[i] = 0;
} else if (short_[i] == 1){
branch[i] = 10;
nshort_[i] = 1;
eprice = C[i];
inShort = 1;
ncover_[i] = 0; nsell_[i] = 0;
} else {
branch[i] = 11;
ncover_[i] = 0;
nsell_[i] = 0;
}
}
} //end inBuy == 0
veprice[i] = eprice; VInBuy[i] = inBuy; VInShort[i] = inShort;
}
printf("nBuy_= %g nSell_= %g\n", nBuy_, nSell_);
printf("nShort_ = %g nCover_= %g\n", nShort_, nCover_);
printf("inBuy = %g inShort = %g\n", vinBuy, vinShort);
printf("Branch= %g \n", branch);
Plot( C, "Close", colorBlack, styleNoTitle | ParamStyle("Style") | GetPriceStyle());
Plot(stopLine , _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style",styleNoLabel, maskDefault) );
// plot shapes with colors that are different from candle colors
PlotShapes( shapeSmallUpTriangle*nBuy_, colorBlue );
PlotShapes( shapeHollowSmallDownTriangle*nSell_, colorBlue );
PlotShapes( shapeSmallDownTriangle*nShort_, colorYellow );
PlotShapes( shapeHollowSmallUpTriangle*nCover_, colorYellow );
------------------------------------
**** 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/
|