PureBytes Links
Trading Reference Links
|
Hello All! I need help! Sorry for my bad English... I try to write code for auto trading with some local trading terminal. I`ve done nearly my task but... Here code: EnableScript("_vbscript_");
<% Dim AD Set AD = CreateObject("ADLite.AlfaDirect")
function OrderBuy(vbprice) vbordernum = AD.CreateLimitOrder ("11111-000", "FORTS", "RTSI-12.09", "24.10.09 23:00", "Buy comment", "RUR", "B", "1", vbprice, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, 10) OrderBuy = vbordernum End function
function OrderSell(vbprice) vbordernum = AD.CreateLimitOrder ("11111-000", "FORTS", "RTSI-12.09", "24.10.09 23:00", "Sell comment", "RUR", "S", "1", vbprice, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, 10) OrderSell = vbordernum End function
%>
TickerID=1; Ticker="RTSI-12.09"; TimeFrame=1; Seccode="RTSI-12.09";
Otstup=-2;
////////// my System /////////////// Buy= Cross(C, EMA(C,12)); Sell= Cross(EMA(C,12) , C); Short=0;Cover=0; Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);
Equity( 1 ); GraphXSpace = 9; Plot(C,"price",12,1); PlotShapes(IIf(Buy,shapeUpArrow,0),5,0,Graph0,-15); PlotShapes(IIf(Sell,shapeDownArrow,0),4,0,Graph0,-15); Plot( Volume, "Volume", 0, styleHistogram | styleOwnScale, 1,110000 );
//////////////////////////////////////////////////////////////////////////////////
if ((Now(3)==LastValue(DateNum()))AND(BarCount>1)AND(Name()==Ticker)AND(TimeFrame==Interval()/60)AND((Buy[BarCount-1]==1)OR(Sell[BarCount-1]==1)OR(Short[BarCount-1]==1)OR(Cover[BarCount-1]==1))) { ifbuy=IIf(Buy[BarCount-1]==1,1,0); ifsell=IIf(Sell[BarCount-1]==1,1,0); ifshort=IIf(Short[BarCount-1]==1,1,0); ifcover=IIf(Cover[BarCount-1]==1,1,0); if (ifbuy) { price=(1+Otstup/100)*Close[BarCount-1]; script = GetScriptObject(); OrderNum = script.OrderBuy (price); WriteVal (OrderNum);
} if (ifsell) { price=(1-Otstup/100)*Close[BarCount-1]; script = GetScriptObject(); OrderNum = script.OrderSell (price); WriteVal (OrderNum);
} if (ifshort) { price=(1-Otstup/100)*Close[BarCount-1]; OrderNum = script.OrderSell (price); WriteVal (OrderNum);
} if (ifcover) { price=(1+Otstup/100)*Close[BarCount-1]; OrderNum = script.OrderBuy (price); WriteVal (OrderNum);
} }
This code work. My orders delivers to terminal . But After Refreshing Chart in Amibroker I receive the same orders again and again until bar on which signal come don`t change to next. For ex: If i use 1 minute time frame than i have 2 equal orders, because Realtime Chart Refresh Interval have a limit with 30 seconds. So i need advice how to prevent duplicate orders! If i can increase Realtime Chart Refresh Interval to 1 minute than i solve my problem for 1 minute frame !... but there 5,15 and hours time frames. I think i have to write some AFL code or VB code to perform my task. Thanks in advance for any help!
__._,_.___
**** 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/
__,_._,___
|