SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Aug 21, 2019 5:14 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Mon May 11, 2009 3:59 pm 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
Using an internal trailing stop implemented with SetStop, I would like to vary the stop loss distance (StopLevel) during the strategy. For example, I might want to use a distance (level) parameter of 1.0 initially, and then increase the distance to 2.0 if prices move in my favor while the position is open.

What is the best way to change the level once a SetStop has been created? Should I just create a whole new stop object like this
Code:
     // change the stop loss distance
     SetStop (2.0, StopType.Trailing, StopMode.Absolute)


Or should I maintain a reference to the orginal stop object, and just change the level inside the object directly, like this:
Code:
// reference to the stop object
Stop mystop;

OnPositionOpened (...) {
     // create a stop loss on the new position
     mystop = SetStop (1.0, StopType.Trailing, StopMode.Absolute)
    ...
}

OnBar (Bar bar) {
    ...
    // adjust the stop loss distance as prices move around
    mystop.Level = 2.0;
    ..
}


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

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