SimpleStrategy.csshine

Strategies are published here.

Moderator: admin


Re: SimpleStrategy.csshine

Postby csshine » Tue Dec 18, 2018 11:35 pm

-- 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


Dear, I found a issue when running the strategy.
If there is already a buy trade, during the cycle of buy trade, new generated sell order will force the buy trade to be close and new sell order will be closed too. I think the correct situation is that these two trades will be run separately.
Could you help to debug why this situation happened?
csshine
 
Posts: 12
Joined: Wed Nov 28, 2018 6:16 am

Re: SimpleStrategy.csshine

Postby Apprentice » Thu Dec 20, 2018 1:58 pm

Test.png

We think it depends on the type of account. we assume you have an account without hedging?
See attach test using sim mode with hedging.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Custom Strategies

Who is online

Users browsing this forum: No registered users and 21 guests