Please help me to place an order pegged to bid price and modify order whenever bid price changes. I have attached two codes here below. Do they work or is there a better way out.
// Option 1
ask = GetRTData("Ask");
bid = GetRTData("Bid");
last = GetRTData("Last");
price = bid;
orderID = ibc.ModifyOrder(orderID,sTicker, "BUY", order_qty, "LMT", price, 0, "DAY", True);
// Will this order modify automatcially as and when bid price changes?
//Option 2. Is the follwing approach correct?
ask = GetRTData("Ask");
bid = GetRTData("Bid");
last = GetRTData("Last");
price = bid;
new_price = GetRTData("Bid");
if (new_price != price)
{
orderID = ibc.ModifyOrder(orderID,sTicker, "BUY", order_qty, "LMT", new_price, 0, "DAY", True);
}
//if you have any better suggestions please