SimpleStrategy.csshine
Posted: Fri Dec 14, 2018 1:14 pm
Your last stop on a way to find a fast growing community of forex traders and software developers. Best forex charts indicators are available here for download. Custom development of indicators and translation to .LUA is also available on request.
http://fxcodebase.com/code/
-- 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