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

Re: [amibroker] help coding autotrade to tws



PureBytes Links

Trading Reference Links

http://finance.groups.yahoo.com/group/AmiBroker-at/


Saturday, February 10, 2007, 5:22:15 AM, you wrote:

> hi,
> Im trying to get amibroker to send orders to tws ( on the eur/usd)
> i found some code to i added to my afl, but it keeps sending orders
> could someone help to get this to work, thanks
> ( i d like the system to buy when trix cross the 0 line, and to
> reverse when it crosses the oder way)

> thanks for your help


> st= Optimize( "st", 34, 2, 100, 1 );



> Buy =Cover=Cross( Trix(st), 0);
> Sell=Short = Cross( 0,Trix(st));




> SetPositionSize( 1, spsShares );




> if( LastValue( Buy ) )
> {
> ibc = GetTradingInterface("IB");

> // check if we are connected OK
> if( ibc.IsConnected() )
> {
> // check if we do not have already open position on this stock
> // if( ibc.GetPositionSize( Name() ) == 0)
> {
> // transmit order
> ibc.PlaceOrder( Name(), "Buy", 25000, "MKT", 0, 0, "Day",
> True );
> }
> }
> }




> if( LastValue( Sell ) )
> {
> ibc = GetTradingInterface("IB");

> // check if we are connected OK
> if( ibc.IsConnected() )
> {
> // check if we do not have already open position on this stock
> //if( ibc.GetPositionSize( Name() ) == 0 )
> {
> // transmit order
> ibc.PlaceOrder( Name(), "sell", 25000, "MKT", 0, 0, "Day",
> True );
> }
> }
> }


> if( LastValue( Short ) )
> {
> ibc = GetTradingInterface("IB");

> // check if we are connected OK
> if( ibc.IsConnected() )
> {
> // check if we do not have already open position on this stock
> // if( ibc.GetPositionSize( Name() ) == 0 )
> {
> // transmit order
> ibc.PlaceOrder( Name(), "sell", 25000, "MKT", 0, 0, "Day",
> True );
> }
> }
> }
> if( LastValue( Cover ) )
> {
> ibc = GetTradingInterface("IB");

> // check if we are connected OK
> if( ibc.IsConnected() )
> {
> // check if we do not have already open position on this stock
> // if( ibc.GetPositionSize( Name() ) ==0)
> {
> // transmit order
> ibc.PlaceOrder( Name(), "Buy", 25000, "MKT", 0, 0, "Day",
> True );
> }
> }

> }




> 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




Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.35/680 - Release Date: 2/10/2007 9:15 PM