Hi team,
I have been trading manually (thru IB) and I do need the auto trading to improve discipline. I have read the AT section in Amibroker but I can’t even send the order to IB thru the IBC. Please help me. Many thanks. Below please see sample of my simple strategy to trade Hong Kong listed futures “HHI”.
I have basic PC skills so please forgive me for my ignorance below… I should have studied computer science…
Q1. May I know what does the bracket { } mean for? Are they essential for Buy, Sell orders?
Q2. I trade Hong Kong HHI futures only. The Symbol used in Amibroker is “HHIM17-HKFE-FUT-HKD”. Is this supposed to be the code used in the below ibc Placeorder condition? or “HHIM17” is good enough?
Q3. I would like to place stoploss(mkt) order right after the initial trade is executed. Stop loss limit will be 0.6% of the executed price. May I know how to input it into the ibc Placeorder condition?
//place mkt order when there is Buy Signal
parentID = ibc.PlaceOrder("HHIM17","BUY",1,"MKT",0,0,"DAY",False);
//stop loss order 0.6% stop loss limit
ibc.PlaceOrder("HHIM17", "SELL", 1, "LMT","STP",[???what shall I input here],0,"DAY", False,1,"", parentID );
Q4. Does string action have “Buy”, “Sell”, “SShort” only? For my strategy below, will IBC execute Buy trade for Buy and Cover and Sell trade for Sell and Short trade?
Is there anything in the library which I can refer to to learn teh basics? Many thanks
SK
SetPositionSize(1,spsShares);
RSIO=Optimize("RSIO",45,15,51,3);
BBWidthNum=Optimize("BBWidthNum",20,10,30,3);
BBTop = BBandTop (Close,RSIO,2); //Upper Bollinger Band
BBBottom = BBandBot (Close,RSIO,2); //Lower Bollinger Band
BBWidth = BBTop-BBBottom; // Bollinger Band Width My Calculation
Firsttrade=133000;
Lasttrade=155800;
ForceExitTime=162500;
Buy = (Ref( Low , -1 ) < Ref( BBandBot( Close, RSIO, 2 ) , -1 )) AND BBWidth>=BBWidthNum AND TimeNum()<Lasttrade AND TimeNum()>Firsttrade;
Sell = High > BBandTop( Close, RSIO, 2 ) OR TimeNum()>Forceexittime;
Short = Ref( High , -1 ) > Ref( BBandTop( Close, RSIO, 2 ) , -1 ) AND BBWidth>=BBWidthNum AND TimeNum()<Lasttrade AND TimeNum()>Firsttrade;
Cover = Low < BBandBot( Close, RSIO, 2 ) OR TimeNum()>Forceexittime;
{
//Long, place order
ibc = GetTradingInterface("IB");
if(ibc.IsConnected())// check if connection to IB was successful
{
//place mkt order when there is Buy Signal
parentID = ibc.PlaceOrder("HHIM17","BUY",1,"MKT",0,0,"DAY",False);
//stop loss order 0.6% stop loss limit
ibc.PlaceOrder("HHIM17", "SELL", 1, "LMT","STP",0[executed price*0.994.. asking helpdesk...],0,"DAY", False,1,"", parentID );
}
//short, place order
ibc = GetTradingInterface("IB");
if(ibc.IsConnected())// check if connection to IB was successful
parentID = ibc.PlaceOrder("HHIM17", "SELL", 1, "MKT", 0, 0, "DAY", False );//place mkt order when there is Short Signal
ibc.PlaceOrder("HHIM17", "BUY", 1, "STP",0[executed price*1.006.. asking helpdesk...], 0, "DAY", False, 1, "", parentID );//stop loss order 0.6% stop loss limit
}