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

[amibroker] Backtest futures mode



PureBytes Links

Trading Reference Links

Hi Johan,

it's really two different things. The first was the arrows, which you 
fixed. 
The second is a matter of validating points. Let's say that you have 
two pivot low points that you connect with a demand line. As it turns 
out the close of the bar immediately after the most recent pivot 
point is below the trendline. You can see what problem this creates? 
If the stock opens unchanged the next day it will break the 
trendline. It has to gap up on the open to avoid this. Therefore, if 
the close the day after the most recent pivot low is below the 
trendline that would be drawn, then the pivotpoint is disqualified, 
and the line between the two previous pivot points is kept. Hope you 
understand. I have a vague idea on how to do it, but haven't tried it 
yet.
By the way, here is the code I use now:

Plot(C,"",colorBlack,styleBar);
pivothigh = Ref(C,-3)<H AND Ref(H,-2)<H AND Ref(H,-1)<H AND H>=Ref
(H,1);
pivotlow = Ref(C,-3)>L AND Ref(L,-2)>L AND Ref(L,-1)>L AND L<=Ref
(L,1);

x1=LastValue(ValueWhen(pivotlow,Cum(1)-1,1));
y1=LastValue(ValueWhen(pivotlow,L,1));
x0=LastValue(ValueWhen(pivotlow AND L<y1,Cum(1)-1,1));
y0=LastValue(ValueWhen(pivotlow AND L<y1,L,1));
x3=LastValue(ValueWhen(pivothigh,Cum(1)-1,1));
y3=LastValue(ValueWhen(pivothigh,H,1));
x2=LastValue(ValueWhen(pivothigh AND H>y3,Cum(1)-1,1));
y2=LastValue(ValueWhen(pivothigh AND H>y3,H,1));

supplyline=IIf(x2==0,Null,LineArray(x2,y2,x3,y3,1));
Plot(supplyline,"",colorRed,styleLine|styleThick|
styleNoRescale|styleNoLabel);
demandLine=IIf(x0==0,Null,LineArray(x0,y0,x1,y1,1));
Plot(demandLine,"",colorBlue,styleLine|
styleThick|styleNoRescale|styleNoLabel);

PlotShapes((Cum(1)-1==x0 OR Cum(1)-1==x1)
*shapeSmallCircle,colorBlue,0,L);
PlotShapes((Cross(Cum(L<demandLine AND Cum(1)-2>x1),0))
*shapeDownArrow,colorRed,0,H);
PlotShapes((Cum(1)-1==x2 OR Cum(1)-1==x3)
*shapeSmallCircle,colorRed,0,H,12);
PlotShapes((Cross(Cum(H>supplyline AND Cum(1)-2>x3),0))
*shapeUpArrow,colorGreen,0,L);

Title= Name()+" "+Date()+EncodeColor(colorBlack) +" Open-"+WriteVal
(Open)+" Hi-"+WriteVal(High)+" Lo-"+WriteVal(Low)+" Close-"+WriteVal
(Close) +EncodeColor(colorRed)+" supply line "+WriteVal(supplyline)
+EncodeColor(colorBlue)+" demand line "+WriteVal(DEMAndline)
+EncodeColor(colorRed)+"\n potential Buy "+WriteVal((y3-y2)/(x3-x2)
+LastValue(supplyline))+EncodeColor(colorBlue)+" potential 
Sell "+WriteVal((y1-y0)/(x1-x0)+LastValue(DEMAndline));
GraphXSpace=6;
--- In amibroker@xxxxxxxxxxxxxxx, "johsun" <johanskatt@xxxx> wrote:
> Hi Martin,
> 
> You wrote:
> > Do you know how to code the other crieteria for the lines, i.e. 
> the 
> > close on the day immediately after a pivot cannot exceed the new 
> > trendline?
> 
> 
> 
> If you mean what you wrote earlier, that arrows should be excluded 
> from the day after a pivotbar then that's what this change 
achieves. 
> 
> 
> 
> > > Just change Cum(1)-1 to Cum(1)-2 in these lines:
> > > 
> > > PlotShapes((Cross(Cum(C<demandLine AND Cum(1)-1>x1),0))
> > > *shapeDownArrow,colorRed,0,H);
> > > 
> > > PlotShapes((Cross(Cum(C>supplyline AND Cum(1)-1>x3),0))
> > > *shapeUpArrow,colorGreen,0,L);
> > > 
> > > 
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "marmal417" <marmal@xxxx> 
> wrote:
> > > > Next thing is really to remove up and down arrows from the 
bar 
> > > after 
> > > > a pivot point. Since a line is only drawn once the pivot 
point 
> is 
> > > > completed, it can't really be broken during the day 
> immediately 
> > > after 
> > > > a pivot point because the line isn't drawn until after the 
> close 
> > > of 
> > > > that day. Anyway, is there a way to exclude arrows from the 
> day 
> > > after 
> > > > the pivot?
> > > > 
> > > > Another thing Demark writes about is the reliability of lines 
> > > which 
> > > > are penetrated at the close the day after the pivot point. 
> Let's 
> > > take 
> > > > for example a new pivot low being created. Upon completion of 
> > this 
> > > > most recent pivot low (higher lows on both sides) you connect 
> the 
> > > > second most recent pivotlow with this newformed one. As it 
> turns 
> > > out, 
> > > > the line that is drawn between the two pivotlows is 
penetrated 
> by 
> > > the 
> > > > close of the day after the most recent pivotlow, i.e. the 
last 
> > day 
> > > on 
> > > > the chart if a new pivotlow has just been created. In that 
> case, 
> > > says 
> > > > Demark, it raises the question of reliability regarding that 
> > > specific 
> > > > line. 
> > > > To program this I guess you would have to calculate the slope 
> of 
> > > the 
> > > > trendline and add that value to the low of the last pivotlow 
> > > (since 
> > > > the trendline crosses through that point) and check whether 
or 
> > not 
> > > > the close the day after is lower than the value of the line. 
> And 
> > > if 
> > > > it is lower, no line would be drawn.
> > > > Demark writes that a close below the demand line on the day 
> after 
> > > a 
> > > > pivotlow doesn't necessarily invalidate that line, but I 
think 
> > > it's 
> > > > better to assume that is the case. Because in order for the 
> line 
> > > not 
> > > > to be broken the next day, the stock would have to gap up 
past 
> > the 
> > > > line again and never retrace back to the line during the day.
> > > > 
> > > > Hope you understand me.
> > > > 
> > > > //Martin



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

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

<*> 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/