SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Sep 24, 2018 3:21 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Jan 03, 2011 9:40 pm 
Offline

Joined: Thu Jul 23, 2009 2:02 pm
Posts: 22
Hi, Could anyone help me how to add stop limit order in this code ? Currently it only send target exit limit order (SellLimitOrder) in OmPositionOpened() but I would like to add stop limit order for downside risk. I added stop order code but it doesn't seem to to work..
Thanks.

public override void OnPositionOpened()
{
// when a position is opened, calculate profit target
exitPrice = buyOrder.AvgPrice * (1 + ProfitPercent / 100);
// cancel existing sell order if there is one
if (sellOrder != null)
sellOrder.Cancel();
// issue a new sell limit order at the profit target price
sellOrder = SellLimitOrder(Qty, exitPrice, "Exit (Profit Target)");
sellOrder.Send();

/*** stop Order added by me **/

stopPrice = buyOrder.AvgPrice - ticks_stop
if (stopOrder != null)
stopOrder.Cancel();
stopOrder = SellStopOrder(Qty, stopPrice, "Exit(Stop Loss)" + OCACount);
stopOrder.Send();

}


Top
 Profile  
 
PostPosted: Mon Jan 03, 2011 10:05 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6808
I've just replied you in this thread

viewtopic.php?f=46&t=5210

Regards,
Anton


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


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