this has been covered many times on the AmiBroker-at list.
herman
Thursday, March 8, 2007, 4:13:41 PM, you wrote:
> Hello,
> Did you ever get the answer to this problem. I am having the same
> issue.
> Thanks.
> --- In amibroker@xxxxxxxxxxxxxxx, "cftrading1" <cftrading1@xxx>
> 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
> <*> 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/
>
__._,_.___
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
SPONSORED LINKS
__,_._,___
|