PureBytes Links
Trading Reference Links
|
> sorry i didnt mean the profits, i am mainly interested in having the
> exploration
> have the correct buy and sell dates as in a backtest.
In that case just use Equity(1) instead of ExRem,
as I have shown in my previous response.
See also for details
http://www.amibroker.com/guide/afl/afl_view.php?name=EQUITY
If you really want to use ExRem you should apply them
to actual Buy and Sell signals not to the copies (buy2, sell2 temporary variables):
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "amiabilityy" <amiabilityy@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, May 04, 2003 8:20 PM
Subject: [amibroker] Re: T.J. Random exits on same bar in Exploration , WHY?
> Hi TJ.
>
>
>
> In an ami backtest it will buy and sell on the same bar.
> If there was a buy condition on that bar again it will buy on this
> day again, and sell at a different date, in simple terms sometimes it
> will buy on the open of a sell day even though
> there was a sell at the close.
>
> I have not been able to do this in an exploration.
>
> (of coarse i would not want this in an exploration, or backtest), i
> was only trying to do the same in an exploration as i thought they
> worked in a similar way.
>
>
>
> The buy and sell conditions are only to test if the code works as it
> will either buy and sell on separate bars or on the same bar.
>
> I have the filter as 1 to check if the
> buysell and sellsell columns have the correct buy and sell prices.
>
> All the data will be in 1 row.
>
> So when there is a sell , the buy and sell imformation will be in the
> 1 row.
> This is due to the number of rows limit in excel.
>
> When commenting out these lines
>
> Buy=ExRem(Buy2,Sell2);
> Sell=ExRem(Sell2,Buy2);
>
> in the code, the buy and sells on the same bar seem o.k.
> but there are excesive signals.
>
> In my test (when using exrem)there was a buy and sell on the same
> bar,
> This was not triggered.
>
> about 3 bars later the same condition happened and this was
> triggered.
>
>
>
>
>
>
>
> sdelayy=0;
> Buyarray=O;
> Sellarray=C;
> Buy=Cross(C,MA(C,20));
> Sell=Cross(C,MA(C,2));
> AddColumn(Buy ,"buy ");
> AddColumn(Sell ,"sell ");
>
> Buy2=Buy;
> Buy2=ExRemSpan(Buy2 ,delayy);
> Buy2=Ref( Buy2,-delayy );
> Sell2=Sell;
> Sell2= ExRemSpan(Sell2,sdelayy );
> Sell2=Ref(Sell2,-sdelayy);
>
>
> Buy=ExRem(Buy2,Sell2);//If using exrem somtimes it will buy and sell
> on same bar,
> // it affects the cumvalue counter, in the buycum column so when
> there should be a //buy, the count did not increase, but at other
> times will increase.
> Sell=ExRem(Sell2,Buy2);
>
>
> Buycum=Cum(Buy);
> Sellcum=Cum(Sell);
> newtradeb=Buycum>Ref(Buycum,-1) OR Buycum>0 AND Ref(Buycum,-1)==0;
> newtrades= sellCum>Ref(sellCum,-1);
> Buyvalue=ValueWhen(1,Buyarray ,1);
> Sellvalue=ValueWhen(1,Sellarray,1);
>
> newtradeb=ValueWhen(Buycum,Buy,1)>ValueWhen(Buycum,Buy,2) OR Buycum>0
> AND Ref(Buycum,-1)==0;
> newtrades=ValueWhen(sellCum,Sell,1)>ValueWhen(sellCum,Buy,2) AND
> buycum>0;
>
> Buy=newtradeb;
> Sell=newtrades;
>
> Buyvalue=ValueWhen(1,Buyarray ,1);
> Sellvalue=ValueWhen(1,Sellarray,1);
>
> Filter= 1;//Sell AND buycum>=0;
>
> AddColumn(IIf(Sell,ValueWhen(Buy,Ref
> (Buyvalue,0 ),1),0),"buysell",1.4);
> AddColumn(IIf(Sell,ValueWhen(Sell,Ref
> (sellvalue,0),1),0),"sellsell",1.4);
> AddColumn(Buyvalue,"buyprice",1.4);
> AddColumn(sellvalue,"sellprice",1.4);
> AddColumn(Buy ,"buy ");
> AddColumn(Sell ,"sell ");
> AddColumn(Buycum ,"buycum ");
> AddColumn(Sellcum ,"sellcum ");
> AddColumn(newtradeb ,"newtradeb ");
> AddColumn(newtrades ," newtrades");
>
>
>
>
> Peter.
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx>
> wrote:
> > Hello,
> >
> > 1. You don't give any source to look at so it is impossible
> > to answer to the question why your code does not work.
> > 2. If you really want to simulate backtest in exploration
> > (although I don't know why you ever would),
> > you should use add Equity(1) after your trading rules
> > to make the backtest routine eliminate extra signals
> > and evaluate stops.
> >
> >
> > ApplyStop()s
> > buy=
> > sell =
> > short =
> > cover =
> >
> > Equity(1);
> >
> > AddColumn(...)s
> >
> > See also settings ("allow same day exits" -
> > you should however note that this is BACKTESTER
> > setting)
> >
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message -----
> > From: "amiabilityy" <amiabilityy@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Sunday, May 04, 2003 6:29 PM
> > Subject: [amibroker] T.J. Random exits on same bar in Exploration ,
> WHY?
> >
> >
> > > hi
> > >
> > > Has anyone written code that emulates a backtest.
> > >
> > > I have tried to do this to export data to excel,
> > > but i cant get the exploration to act exactly as the
> backtester.
> > > ( using exrem on a backtest and the exploration).
> > >
> > > sometimes it will buy and sell if a buy and sell fall on the
> same
> > > bar, other times it doesnt buy or exit on the same bar if a buy
> and
> > > sell condition were true on a bar.
> > > (this happens when using exrem)
> > >
> > > I cant understand this, it almost seems random
> > >
> > >
> > > If the buy and sells are on separate bars there is no problem.
> > >
> > > Why is it not consistant when there are buy and sells on the
> same
> > > bar, when using exrem.
> > >
> > > Is there another function or a rule i need to use in an
> > > exploration.
> > >
> > > Peter.
> > >
> > >
> > >
> > >
> > > Send BUG REPORTS to bugs@xxxx
> > > Send SUGGESTIONS to suggest@xxxx
> > > -----------------------------------------
> > > 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
> > >
> > > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> > >
> > >
> > >
>
>
>
> 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
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/YoVfrB/XP.FAA/uetFAA/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
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|