PureBytes Links
Trading Reference Links
|
Hi Graham,
I am so sorry I was unable to be more precise about what I am trying to do. Actually what you said is pretty interesting but it is not exactly what I am trying to do.
I want to set buyprice as a % of the actual bar trade (the bar after the signal bar). E.g. If the signal was at 2:10 P.M. at 20.00$, then I want the backtest to consider that I was in at 2:11 P.M. at the Close of that bar + X%. Let's say the close of bar at 2:11 is 20.1, then the backtester would consider I bought at 20.31, (20.1 + 1%). Of course, there is no information about any 20.31 bar at that time and of course in real-time trading that wouldn't happen (and of course 1% is not necessarily what I would put for a 20$ stock) but the idea is to make it more difficult to make a profit and to take in fact the difference between bid and ask that I could face in less liquid markets. You see: a bar could show a close of 3.5$, as an example, but if the stock is not liquid I may have to buy it at 3.60$. This is what I am trying to do: set a slippage adjustement which will vary depending on liquidity.
I think I understand from what you say that it is difficult because the backtester can not consider a buy which is higher than the high of the bar. How can I go around this problem?
Again, this is not for real-time trading ( I do not want to issue conditionnal order), but simply to set a slippage penalty which will be a function of liquidity.
Thanks!
Louis
2008/7/1 Graham < kavemanperth@xxxxxxxxx>:
You already have the prices defined, not sure what you are wanting. We
need more description.
I am making an educated guess that you want the price to be %
different to the value of Close on the signal bar, ie previous bar to
actual trade
buyprice = ref(c,-1)*1.01;
Now if the next bar after the signal does not actually have this price
in its range then you need to add conditions to your signals and maybe
more options to the price definition. This now comes to how you
actually trade, how you enter orders to your broker and how these are
actually carried out. There are many different methods depending on
the market you trade, your broker and how orders are done etc.
As an example when you get a signal you send a conditional order to
your broker to enter buy next day at 1.01*Close
Now does this get carried out if the prices traded the next day are
above the order price, or only if there is trade at that price, or
other?
If the trade is only acted if the next bar range covers the price then
you need to add condition (for backtesting) that the next bar range is
around the order price. eg
buy = Other Conditions and ref( L<=buyprice and h>=buyprice, 1);
If your order gets done if the next bar price just has to trade higher then
buy = Other Conditions and ref( h>=buyprice, 1);
buyprice = max(open,ref(c,-1)*1.01);
This is only one single simple possibility
Do not worry that in your backtest the afl is looking to the future,
because your actual trades taken should reflect real life situation.
Maybe I am adding more than you are asking, or have missed the point.
Can only answer based on level of detail provided.
2008/7/2 Louis Préfontaine < rockprog80@xxxxxxxxx>:
> Hi Graham,
>
> How can I put more information so that my buy price is 1% higher than C and
> sell price 1% lower than C?
>
> Thanks,
>
> Louis
>
> 2008/7/1 Graham < kavemanperth@xxxxxxxxx>:
>>
>> Without more information on what you are trying to achieve
>> The price will be for the bar of actual entry C*1.01 or C*0.99
>>
>> Also the prices may be outside than the bar range in which case the
>> closer of high or low is used if you have the PriceBoundChecking on
>>
>> --
>> Cheers
>> Graham Kav
>> AFL Writing Service
>> http://www.aflwriting.com
>>
>> 2008/7/1 Louis Préfontaine < rockprog80@xxxxxxxxx>:
>>
>> > Hi,
>> >
>> > I have been trying to set a formula for slippage:
>> >
>> > SetTradeDelays( 1, 1, 1, 1 );
>> >
>> > BuyPrice = C*1.01;
>> > SellPrice = C*0.99;
>> >
>> > It doesn't work at all. I tried to write C*50 just for fun, but it
>> > didn't
>> > change the buyprice at all. What can possibly be wrong?
>> >
>> > Thanks,
>> >
>> > Louis
>
__._,_.___
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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
__,_._,___
|