PureBytes Links
Trading Reference Links
|
Hi. Is it possible that you are not seeing some expected arrowhead plots because they are lost in the candle coloring?
IOW, is there still a problem if you try this:
// 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 );
--- In amibroker@xxxxxxxxxxxxxxx, "redberryys" <redberryys@xxx> wrote:
>
> Hi all,
>
> I hope this is the right place to post this - apologies otherwise & please redirect me to the right place.
> I'm trying to filter some signals using a for loop.
> I print the variables in the loop and I 'plotShapes' the same variables. Results are erratic and inconsistent.
> If I move the selection bar, the values printed with printf do not match what is displayed with plotShapes, and both seem to be incorrect [they do not reflect the code in the loop, in some instances].
> I use this on EUR.USD-IDEALPRO-CASH , 1 min chart, but the same problem happens with other tickers and timeframes. I use Amibroker 5.24 beta, but it happens with 5.20 as well.
> Has anyone encountered this before? What could be the problem?
>
> Thank you,
> Alex
>
> Here's the code, with a few debug aids included:
>
> SetBarsRequired( -1, -1 );
> OptimizerSetEngine("cmae");
>
> stoplineThrL = Optimize("stoplinethrL ", 0.0003, 0,0.001,0.0001);
> stoplineThrS = Optimize("stoplinethrS ", 0.0000, 0,0.001,0.0001);
> PositionSize= Optimize( "PositionSize", -75, -95,-10,5);
> lMaxLoss = Optimize( "lMaxLoss", 0.002 , 0.0006,0.01,0.0001);
> lMinGain = Optimize( "lMinGain", 0.0015, 0.0007,0.01,0.0001);
> shMaxLoss = Optimize("shMaxLoss", 0.002 , 0.0005,0.01,0.0001);
> shMinGain = Optimize("shMinGain", 0.0015, 0.0085,0.01,0.0001);
>
> 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;
> ShortPrice =Max(L,Min(O,stopline)); BuyPrice = Min(H,Max(O,stopline));//reasonable estimate
>
> Buy_=rmacd_h>0 && rC > rstopLine && !stopin && stopline > rstopline && rmacd_h < macd_h ;
> Sell_= (L < rstopLine-stoplineThrL);
> SellPrice = Max(L,Min(H,rstopLine-stoplineThrL-0.0001));//-0.000002;
>
> Short_=rmacd_h<0 && rC < rstopLine && !stopin && stopline < rstopline && rmacd_h > macd_h;
> Cover_=(H > rstopLine+stoplineThrS);
> CoverPrice = Min(H,Max(L,rstopLine+stoplineThrS+0.0001));//+0.00005;
>
> Plot( C, "Close", colorBlack, styleNoTitle | ParamStyle("Style") | GetPriceStyle());
> Plot(stopLine , _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style",styleNoLabel, maskDefault) );
>
> //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
>
> 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){
> branch[i] = 1;
> nbuy_[i] = 0; nshort_[i] = 0; ncover_[i] = 0;
> if (sell_[i]){
> branch[i] = 2;
> if (C[i] > (eprice - lMaxLoss) && C[i] < (eprice + lMinGain)) {
> branch[i] = 3;
> nsell_[i] = 0;
> } else {
> branch[i] = 4;
> nsell_[i] = 1;
> inBuy = 0;
> }
> }
> // continue;
> } else if (inShort){
> branch[i] = 5;
> nbuy_[i] = 0; nsell_[i] = 0; nshort_[i] = 0;
> if (cover_[i]){
> if (C[i] < (eprice + shMaxLoss) && C[i] > (eprice - shMinGain)) {
> branch[i] = 6;
> ncover_[i] = 0;
> } else {
> branch[i] = 7;
> ncover_[i] = 1;
> inShort = 0;
> }
> }
> // continue;
> } else {
> branch[i] = 8;
> if (buy_[i]) {
> branch[i] = 9;
> nbuy_[i] = 1;
> eprice = BuyPrice[i];
> inBuy = 1;
> ncover_[i] = 0; nshort_[i] = 0; nSell_[i] = 0;
> // continue;
> } else if (short_[i]){
> branch[i] = 10;
> nshort_[i] = 1;
> eprice = ShortPrice[i];
> inShort = 1;
> ncover_[i] = 0; nsell_[i] = 0;
> // continue;
> } else {
> branch[i] = 11;
> ncover_[i] = 0;
> nsell_[i] = 0;
> }
> }
> veprice[i] = eprice; VInBuy[i] = inBuy; VInShort[i] = inShort;
>
> }
>
> printf("Buy_= %g Sell_= %g\n", nBuy_, nSell_);
> printf("Short_ = %g Cover_= %g\n", nShort_, nCover_);
> printf("inBuy = %g inShort = %g\n eprice %g\n", vinBuy, vinShort, eprice);
> printf("Branch= %g \n", branch);
>
> PlotShapes(shapeSmallUpTriangle*nBuy_,colorBrightGreen);
> PlotShapes(shapeHollowSmallDownTriangle*nSell_,colorBrightGreen);
> PlotShapes(shapeSmallDownTriangle*nShort_,colorRed);
> PlotShapes(shapeHollowSmallUpTriangle*nCover_,colorRed);
>
------------------------------------
**** 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/
|