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

Re: [amibroker] Re: Building a small GUI around AmiBroker



PureBytes Links

Trading Reference Links

Hello,

Actually you don't really need to build gui as it is already there
in the form of parameter window that can be used to place orders.
Sample code is included in the docs:
http://www.amibroker.com/at/

Excerpt:

Example 3:

3. Placing/modifying manually from Parameters dialog. Code to be applied in Indicator Builder. (Modified to use new features in 
1.0.2)

This code can be run many times and it will modify existing order as long as it is not transmitted. It uses static variables to 
store orderId from last run.

// Param block
TriggerOrder= ParamTrigger("Place order","Click here to place order");
Mode=ParamToggle("Mode","Modify existing|Always place new order");
ACT = ParamList("Action", "BUY|SELL|SSHORT");
OT = ParamList("Order Type", "MKT|LMT|STP");
TIF = ParamList("Time In Force", "DAY|GTC|IOC");
Ticker = ParamStr("Ticker",Name());
NumShares = Param("Number of Shares",10,10,100,10);
LimitPrice = LastValue(C) + Param("Limit Price offset",0,-0.1,0.1,0.01);
StopPrice = LastValue(C) + Param("Stop price offset",0,-0.1,0.1,0.01);
Transmit = ParamToggle("Transmit","Do NOT transmit|Transmit",0);
TriggerCancel = ParamTrigger("Cancel Order","Click here to Cancel order");

Msg = ""; // this variable stores error message text

// create instance of trading interface
ibc = GetTradingInterface("IB");

// retrieve orderID from previous run, will be empty if no order was placed before
OrderID = StaticVarGetText("OrderID"+Ticker);

if( TriggerOrder )
{
// check if we are connected OK
if( ibc.IsConnected() )
{
   if( Mode == 1 ) OrderID = ""; // if mode set to 'always new' then clear orderid

   // place orders only if we do not have already open position on this symbol
   // place or modify the order - don't transmit yet
   OrderID = ibc.ModifyOrder( OrderID, Ticker,
         ACT, NumShares, OT, LimitPrice, StopPrice, TIF, Transmit);


   // store orderID for next run so we know which order to modify

   StaticVarSetText("OrderID"+Ticker, OrderID);

   if( Mode == 1 )
       Msg = "New order has been placed with ID = ";
   else
       Msg = "Order placed/modified with ID = ";

   Msg = Msg + OrderID + " on " + Now();
}
else
{
   Msg = "Placing order failed because of no connection to TWS";
}
}

if( TriggerCancel )
{
  if( OrderId != "" )
   {
    if( ibc.CancelOrder( OrderId ) )
       Msg = "Request to cancel order " + OrderID + " sent successfully";
    else
       Msg = "Request to cancel order " + OrderID + " failed.";
   }
  else
     Msg = "Can not cancel order becase OrderID is empty";

}

// monitoring code
Title =
Msg +
"\nLast TWS message: "+ ibc.GetLastError(0) +
"\nAvailable funds: " + ibc.GetAccountValue("AvailableFunds")+
"  Gross Pos. Value: " + ibc.GetAccountValue("GrossPositionValue")+
"\nOrderID = "+OrderId+
"\nTicker = "+Ticker+
"\nAction = "+ACT+
"\nShares = "+NumToStr(NumShares,1.0)+
"\nOrderType = "+OT+
"\nLimitPrice = "+NumToStr(LimitPrice,1.3)+
"\nStopPrice = "+NumToStr(StopPrice,1.3)+
"\nTimeInForce= "+TIF+
"\nTransmit = "+NumToStr(Transmit,1.0)+"\n"+
"\nGetStatus = "+ibc.GetStatus( OrderID )+
"\nGetPositionSize = "+ibc.GetPositionSize( Ticker )+
"\nIsConnected = "+NumToStr(ibc.IsConnected(),1.0);

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "murthysuresh" <money@xxxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, April 15, 2009 8:29 PM
Subject: [amibroker] Re: Building a small GUI around AmiBroker


> if you want a gui to do order management, why don't you do it directly against ib.
> http://www.codeplex.com/ibcsharp has a few starter functionality
>
> --- In amibroker@xxxxxxxxxxxxxxx, "agastya.ganti" <agastya.ganti@xxx> wrote:
>>
>> Hi ,
>> I would like to build a Small GUI around AmiBroker to place orders with IB. I would like to trigger the order placement manually 
>> from the GUI (by clicking a button or so) and then calculate the stop loss, profit amount and all of that dynamically using 
>> Amibroker formulae
>> and then place the final order through the IB controller.
>>
>> How do I build the GUI ? Can I build the GUI in VB/C# and call it as a COM component from AmiBroker (not the  other way) and the 
>> button events triggering AmiBroker formulae and all such things?
>>
>> I am sure I am not the first person who likes to do this. What are my options and do you know of any other approaches ?
>>
>> Thanks
>> Ram
>>
>
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>



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

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/