Guys,
I am looking for an auto trading code with Amibroker. I found a amibroker code to connect nest to amibroker. I tried it but it opens a new nest api window everytime it fires an order.
Code is below:
_SECTION_BEGIN("Algo Code");
ClientID = ParamStr("ClientId","6KDA12");
Symbol= ParamStr("Symbol","NIFTY13AUGFUT");
Price=NumToStr(C,8.3,True);
Quantity=Param("Quantity",1,1,100,1);
OE = ParamList("Order Execution","Immediate|On Candle Completion",1);
Exchange = ParamList("Exchange","NSE|NFO|MCX|NCDEX",1);
OrderType = ParamList("Order Type","MARKET|LIMIT",1);
ProductType = ParamList("Product Type","MIS|NRML",1);
AT = ParamToggle("AutoTrade","No|Yes");
if(OE=="On Candle Completion")
{
Buy=Ref(Buy,-1);
Sell=Ref(Sell,-1);
}
RefNumber = Nz(StaticVarGet("RefNumber"));
Checkdt=Nz(StaticVarGet("lastdt"));
dt = LastValue( DateTime() );
Cond=LastValue(Buy) OR LastValue(Sell);
if(AT)
{
plus = CreateObject("Nest.PlusApi");
if(plus)
{
plus.SetObjectName(ClientID);
if(Cond AND Checkdt != dt )
{
if(LastValue(Buy)){plus.PlaceOrder("BUY",RefNumber,Exchange,Symbol,"DAY",OrderType,Quantity,Price,0.0 ,0,ProductType,ClientID);}
if(LastValue(Sell)){plus.PlaceOrder("SELL",RefNumber,Exchange,Symbol,"DAY",OrderType,Quantity,Price,0.0,0,ProductType,ClientID);}
StaticVarSet("RefNumber",RefNumber+1);
StaticVarSet("lastdt",dt );
}
}
}
_SECTION_END();
I feel the problem lies in the following line:
plus = CreateObject("Nest.PlusApi");
But if I change it to:
plus = CreateStaticObject("Nest.PlusApi");
Its giving error when order fires.
Can I have help from patrons. Thanks in advance.
I am looking for an auto trading code with Amibroker. I found a amibroker code to connect nest to amibroker. I tried it but it opens a new nest api window everytime it fires an order.
Code is below:
_SECTION_BEGIN("Algo Code");
ClientID = ParamStr("ClientId","6KDA12");
Symbol= ParamStr("Symbol","NIFTY13AUGFUT");
Price=NumToStr(C,8.3,True);
Quantity=Param("Quantity",1,1,100,1);
OE = ParamList("Order Execution","Immediate|On Candle Completion",1);
Exchange = ParamList("Exchange","NSE|NFO|MCX|NCDEX",1);
OrderType = ParamList("Order Type","MARKET|LIMIT",1);
ProductType = ParamList("Product Type","MIS|NRML",1);
AT = ParamToggle("AutoTrade","No|Yes");
if(OE=="On Candle Completion")
{
Buy=Ref(Buy,-1);
Sell=Ref(Sell,-1);
}
RefNumber = Nz(StaticVarGet("RefNumber"));
Checkdt=Nz(StaticVarGet("lastdt"));
dt = LastValue( DateTime() );
Cond=LastValue(Buy) OR LastValue(Sell);
if(AT)
{
plus = CreateObject("Nest.PlusApi");
if(plus)
{
plus.SetObjectName(ClientID);
if(Cond AND Checkdt != dt )
{
if(LastValue(Buy)){plus.PlaceOrder("BUY",RefNumber,Exchange,Symbol,"DAY",OrderType,Quantity,Price,0.0 ,0,ProductType,ClientID);}
if(LastValue(Sell)){plus.PlaceOrder("SELL",RefNumber,Exchange,Symbol,"DAY",OrderType,Quantity,Price,0.0,0,ProductType,ClientID);}
StaticVarSet("RefNumber",RefNumber+1);
StaticVarSet("lastdt",dt );
}
}
}
_SECTION_END();
I feel the problem lies in the following line:
plus = CreateObject("Nest.PlusApi");
But if I change it to:
plus = CreateStaticObject("Nest.PlusApi");
Its giving error when order fires.
Can I have help from patrons. Thanks in advance.