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

[amibroker] Re: Automatic reliable Selling on Close of Bar



PureBytes Links

Trading Reference Links

Use buy = ref(yourBuyCondition, -1); In other words if you have a buy 
condition at the close of the current bar then that formula will 
cause you to place an order at the end of the current bar / start of 
new bar and will give you a buy signal one second later than you want.
And that buy logic won't fail. If you have a buy condition at the end 
of the bar the order will be sent.

If you want to know why trying to trade the last second of a bar is 
pointless read on.

Lets enter the real world. Now(4) is your system time and that is not 
the same as the bar time developed by the data provider. Your system 
clock can be off quite a bit from the data providers clock. So trying 
to get your system clock in sync with bar time will rarely occur. If 
you are using IB data feed AB uses the system clock to create the 
bars since IBs data does not have an integral time stamp. That will 
make the bars close to your system clock. But the TWS timer will 
rarely will be the same as your system clock.  

Trading in the last second of a 5 minute bar is not really different 
when live trading than trading when your buy conditions are true and 
the bar closes. That will buy at the opening of the next bar, one 
second later, and for all practical purposes will be the same or very 
close to your price. Well it won't really buy one second later. Even 
if you are using ABs AutoTrading interface to send orders to IB the 
delay between your system and the order fill at TWS is probably more 
than a second with a market order. If you are trying to get your 
exact price forget it. Won't happen most of the time due to the 
bid/ask spread, trade volume, etc. I guess I get the price at the 
time of the order once in 10 to 20 orders. Often it is off more than 
an tick or two and if the market is really volatile it will be more 
than that. If you are trying to avoid the gaps you see between the 
close and the open forget that too. It is practically impossible.

Barry   


--- In amibroker@xxxxxxxxxxxxxxx, Peter Braun <bleifish@xxx> wrote:
>
> How can I sell reliable on close of bar (I'm using 5 minutes bars)?
> 
> I've used this code, it tries to sell on last second of the 5 
minute bar:
> 
> Time = Now(4);
> NumSeconds = int(int(Time/100%100)*60+int(Time%100));
> Newperiod = NumSeconds % TimeFrame >= in5Minute-1;
> 
> But it failed yesterday. I suppose, it didn't execute on that last 
second
> for some reason. But I don't know another way.
> 
> Thank you in advance
> 
>   Peter
> 
> 
>       __________________________________________________________
> Gesendet von Yahoo! Mail.
> Dem pfiffigeren Posteingang.
> http://de.overview.mail.yahoo.com
>



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

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
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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