SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Aug 19, 2019 9:30 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Jun 21, 2017 6:35 pm 
Offline

Joined: Tue May 02, 2017 12:41 pm
Posts: 17
Hello,

I am trying to implement the following Bracketorder logic but I am getting incorrect set order error. Any thoughts?

For this example range is 100 and Takeprofit 0.1 and StopLoss 0.9.

protected override void OnOrderFilled(Order order)
{
// Send take profit and stop loss orders.
if (order == buyEntry)
{
// Calculate prices.
double takeProfitPrice = Position.EntryPrice + (range * TakeProfit);
double stopLossPrice = Position.EntryPrice - (range * StopLoss);

// Create orders.
takeProfitOrder = SellLimitOrder(Instrument, Qty, takeProfitPrice, "TakeProfit");
stopLossOrder = SellStopOrder(Instrument, Qty, stopLossPrice, "StopLoss");

// Send orders.
Send(stopLossOrder);
Send(takeProfitOrder);
}
else if(order == sellEntry)
{
// Calculate prices.
double takeProfitPrice = Position.EntryPrice - (range * TakeProfit);
double stopLossPrice = Position.EntryPrice + (range * StopLoss);

// Create orders.
takeProfitOrder = BuyLimitOrder(Instrument, Qty, takeProfitPrice, "TakeProfit");
stopLossOrder = BuyStopOrder(Instrument, Qty, stopLossPrice, "StopLoss");

// Send orders.
Send(stopLossOrder);
Send(takeProfitOrder);
}
else if (order == stopLossOrder)
{
// Cancel take profit order.
if (!takeProfitOrder.IsDone)
Cancel(takeProfitOrder);
}
else if (order == takeProfitOrder)
{
// Cancel stop loss order.
if (!stopLossOrder.IsDone)
Cancel(stopLossOrder);
}
}


Top
 Profile  
 
PostPosted: Fri Jun 23, 2017 1:45 am 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
Without going into your code (I do not know anything about the set order error, sorry), have you searched the forum for other bracket order implementations? maybe one of those implementations would work for your scenario.

I found this link from Anton, which might help.

viewtopic.php?f=64&t=6226


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group