Moderator: admin
-- enter into the specified direction
function MarketOrder(BuySell)
valuemap = core.valuemap();
valuemap.Command = "CreateOrder";
valuemap.OrderType = "OM";
valuemap.OfferID = OfferID;
valuemap.AcctID = Account;
valuemap.Quantity = Amount * BaseSize;
valuemap.BuySell = BuySell;
valuemap.CustomID = CustomID;
-- add stop/limit
valuemap.PegTypeStop = "O";
if SetStop then
if BuySell == "B" then
valuemap.RateStop = Offer.Ask - Offer.PointSize * Stop;
else
valuemap.RateStop = Offer.Bid + Offer.PointSize * Stop;
end
end
if IsNeedTrailing then
valuemap.TrailStepStop = (IsNeedDynamicTrailing and 1 or TrailingStop);
end
--valuemap.PegTypeLimit = "O";
if SetLimit then
if BuySell == "B" then
valuemap.RateLimit = Offer.Ask + Offer.PointSize * Limit;
else
valuemap.RateLimit = Offer.Bid - Offer.PointSize * Limit;
end
end
if (not CanClose) and (instance.parameters.SetStop or instance.parameters.SetLimit) then
valuemap.EntryLimitStop = 'Y'
end
success, msg = terminal:execute(200, valuemap);
if not(success) then
terminal:alertMessage(instance.bid:instrument(), instance.bid[instance.bid:size() - 1], "Open order failed" .. msg, instance.bid:date(instance.bid:size() - 1));
return false, msg;
end
return true, msg;
end
Users browsing this forum: No registered users and 77 guests