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

[amibroker] Using Exrem - Position Counts



PureBytes Links

Trading Reference Links

I have for some time now been trying to figure why I sometimes get
incorrect chart plots using figures based on the buy and sell signals.
eg HighestSince(Buy,H)
I could easily remove the signals from the plots, but not the
subsequent calculated figures. Judging from some comments in the group
I guessed I wasn't the only one having trouble getting this right.

So I set up a simple plot to test how the positioning of Exrem affects
the results. The plot buys on first trading day of each of the first 3
weeks of the each month and sells on the last week. This just ensures
multiple buy signals, a single sell signal and no possible buy/sell
signal overlaps.

The result is that position of the exrem statement makes all the
difference to how the results show. It must be prior to any line that
uses the buy/sell in calculations. (or whatever variable is in the
exrem statement)

Hope this helps some understanding for others. 

I have put in 4 positions of exrem which you just need to use param to
shift between them.

GraphXSpace = 5;
Plot(C,"price",colorWhite,styleBar); //CHANGE COLOUR TO SUIT
SetTradeDelays( 0, 0, 0, 0 );

x = Param("Exrem Position", 1, 1, 4, 1);

Buy = DayOfWeek()<Ref(DayOfWeek(),-1) AND
Sum(DayOfWeek()<Ref(DayOfWeek(),-1),BarsSince(Month()!=Ref(Month(),-1))+1)<=3;
// buy on 1st trading day of week over 1st 3 weeks of month
Sell = DayOfWeek()<Ref(DayOfWeek(),-1) AND
Sum(DayOfWeek()<Ref(DayOfWeek(),-1),BarsSince(Month()!=Ref(Month(),-1))+1)==4;
// sell on 1st trading day of week in last week of month

// POSITION #1 
if(x==1) Buy = ExRem(Buy,Sell);

PlotShapes( Buy * shapeUpArrow, colorGreen, 0, L, -20 );
PlotShapes( Sell * shapeDownArrow, colorRed, 0, H, -20 );

// POSITION #2
if(x==2) Buy = ExRem(Buy,Sell);
Plot( HighestSince(Buy,H), "Highest", colorBlue, styleLine|styleNoRescale );

// POSITION #3
if(x==3) Buy = ExRem(Buy,Sell);
BuyPrice = ValueWhen(Buy,H);
Plot( BuyPrice, "BuyPrice", colorGreen, styleDots|styleNoLine|styleNoRescale );

// POSITION #4
if(x==4) Buy = ExRem(Buy,Sell);

-- 
Cheers
Graham
http://e-wire.net.au/~eb_kavan/


------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

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