Amibroker to Pi Bridge - Connection returns -1

I have done a sample coding in Amibroker and tried connecting Pi Bridge for Semi-automatic trading. Pi Bridge status shows "green" means connected. However, brd.GetConnectionStatus() returns -1 always and no trade is registered under Pi. 

//Code snippet start

OrdCond = LastValue(Buy) OR LastValue(Short) OR LastValue(Sell) OR LastValue(Cover);

brd = Null;

if((OrdCond)) 
{
    if(IsNull(brd)) 
    {
    brd = CreateStaticObject("pibridge.Bridge");
    }
    
    if(!brd.GetConnectionStatus()) brd.Reconnect();

    // TRACE OUTPUT OF brd.GetConnectionStatus() Here = -1

    if(LastValue(Buy))
    {

    // This piece of code doesn't register any trade in Pi - Order Book
    brd.PlaceOrder (Exch, TrdSymbol ,Symbol,"SampleAFL", 1,Qty,0, BuyP, 0, OType, PType, ClientId,"Day");
    }

    if(LastValue(Sell))
    {

    // This piece of code doesn't register any trade in Pi - Order Book
    brd.PlaceOrder (Exch, TrdSymbol,Symbol,"SampleAFL", 2,Qty,0, SellP, 0, OType,PType, ClientId,"Day");
    }

    if(LastValue(Cover))
    {

    // This piece of code doesn't register any trade in Pi - Order Book
    brd.PlaceOrder (Exch, TrdSymbol,Symbol,"SampleAFL",1,Qty,0, CoverP, 0, OType, PType, ClientId,"Day");
    }

    if(LastValue(Short))
    {

    // This piece of code doesn't register any trade in Pi - Order Book
    brd.PlaceOrder (Exch, TrdSymbol,Symbol,"SampleAFL", 2,Qty,0, ShortP, 0, OType,PType, ClientId,"Day");
    }
}
 

When I generate a trace file. Following is the output for brd.GetConnectionStatus()

Date : 1/30/2015 3:14:59 PM Ord Cond : 1 Last Value Buy : 1 LV Sell : 0 LV Short : 0 LV Cover : 1 

Above line means that Buy condition is true and buy shall get initiated.

Date : 1/30/2015 3:14:59 PM Pi Bridge Status - Checked -1

However, Pi Bridge status always returns -1 and brd.PlaceOrder executes but does not log any trade in Pi.

Please suggest steps for resolving above error. I couldn't find any documentation on Pi bridge - i.e. Properties / methods of Pi bridge to debug further. Please suggest a link if you have.

Thanks in anticipation.

Regards,

Birju

Hi Biju,

Check this Link


http://tradingqna.com/15156/amibroker-afl-code-pi-help-needed