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

[amibroker] help coding autotrade to tws



PureBytes Links

Trading Reference Links

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 );
}
}

}



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