Australian (ASX) Stock Market Forum

Amibroker SetTradeDelays(0,0,0,0); - does it work in real life?

Joined
20 February 2014
Posts
180
Reactions
0
Hi All,

Can we run simulations using "SetTradeDelays(0,0,0,0);" instead of "SetTradeDelays(1,1,1,1);"
and expect a realistic result? In the formulas I'm playing with, I get an increase in profitability of over 10% per annum if I use "SetTradeDelays(0,0,0,0); " and this is a huge improvement in overall performance.
I mean, in real life, nothing prevents me from buying or selling at the end of the day at the Close price, on the same day when the signal Buy or Sell was triggered? My buy and sell signals are triggered by the Close Price of the day. I only do long, not short, so the last two numbers are not relevant.

Thanks
Nick
 
Hi Nick --

I assume you are doing the following:
SetTradeDelays(0,0,0,0);
BuyPrice = SellPrice = Close;
// Compute signals
Buy = xxx;
// You are taking a long position at the time of the close of trading at the closing price.

---------------------

That works provided:
1. All of the information you need to generate the signal is available at the time of the close or slightly before. You can use a real-time feed to get the prices needed to compute your indicators a few minutes before the close and assume they will be the closing price. Or you can plug in some prices to see what prices give what signals. Or you can pre-compute the price at which a signal will be generated.
2. The issue you are trading can be traded market-on-close. Or you place a market order a minute before the closing time expecting to get the closing price. Some issues have surrogates that trade for some time beyond the close -- 15 minutes is typical -- so you can generate the signal using the actual closing price from one data series, then take your position in another.

What you are describing is generally a good idea. If you have a system that gives profitable signals for the one-day period from today's close to tomorrow's close, a large portion of that profit happens in the overnight period between today's close and tomorrow's open. You are rewarded for taking the overnight risk.

As always, do your own research. Do not base any decisions on in-sample results. Be certain the system holds up when tested on data that was not used at all during development.

Best regards,
Howard
 
Hi Howard,

Thanks for help. In the meantime I discovered what I was doing wrong. Under settings, I had the option to buy at open, not at close. If the settings are to buy at open and the condition for buy gets triggered later that day, I obviously could not buy earlier that day. So, if I select that I want to buy at open, I must make sure I set the delay to at least 1 day later, after the buy signal is triggered.
Is there any way to specify in AFL that I want to buy at O or C (not having to go under Settings)?
Something like SetBuyOption(O) or SetBuyOption(C).

Thanks,
Nick

Hi Nick --

I assume you are doing the following:
SetTradeDelays(0,0,0,0);
BuyPrice = SellPrice = Close;
// Compute signals
Buy = xxx;
// You are taking a long position at the time of the close of trading at the closing price.

---------------------

That works provided:
1. All of the information you need to generate the signal is available at the time of the close or slightly before. You can use a real-time feed to get the prices needed to compute your indicators a few minutes before the close and assume they will be the closing price. Or you can plug in some prices to see what prices give what signals. Or you can pre-compute the price at which a signal will be generated.
2. The issue you are trading can be traded market-on-close. Or you place a market order a minute before the closing time expecting to get the closing price. Some issues have surrogates that trade for some time beyond the close -- 15 minutes is typical -- so you can generate the signal using the actual closing price from one data series, then take your position in another.

What you are describing is generally a good idea. If you have a system that gives profitable signals for the one-day period from today's close to tomorrow's close, a large portion of that profit happens in the overnight period between today's close and tomorrow's open. You are rewarded for taking the overnight risk.

As always, do your own research. Do not base any decisions on in-sample results. Be certain the system holds up when tested on data that was not used at all during development.

Best regards,
Howard
 
Is there any way to specify in AFL that I want to buy at O or C (not having to go under Settings)?
Something like SetBuyOption(O) or SetBuyOption(C).

Use BuyPrice and SellPrice.

eg. to buy at the close and sell at the close use:

BuyPrice = Close;
SellPrice = Close;
 
Is there any way to specify in AFL that I want to buy at O or C (not having to go under Settings)?
Something like SetBuyOption(O) or SetBuyOption(C).

Thanks,
Nick

You could do this for example

Code:
tradedelay = 0; // entry/exit bar delay

if ( tradedelay > 0 )
{
    pricearray = Open;
}
else
{
    pricearray = Close;
}

SetTradeDelays( tradedelay, tradedelay, tradedelay, tradedelay );
 

Buy = ...;
Sell = ...
Short = ...;
Cover= ...;
 
BuyPrice = SellPrice = pricearray;
ShortPrice = Coverprice = pricearray;
 
You could do this for example

Code:
tradedelay = 0; // entry/exit bar delay

if ( tradedelay > 0 )
{
    pricearray = Open;
}
else
{
    pricearray = Close;
}

SetTradeDelays( tradedelay, tradedelay, tradedelay, tradedelay );
 

Buy = ...;
Sell = ...
Short = ...;
Cover= ...;
 
BuyPrice = SellPrice = pricearray;
ShortPrice = Coverprice = pricearray;

Thank you Trash, nice example
 
Top