View Full Version : Changing the Profit Target
01-04-2007, 07:34 AM
From a strategy script, can I change the target in SetProfitTarget elsewhere other than ininitialize()?
01-04-2007, 09:39 AM
No, this method is not intended to dynamically changea profit target, from what I recall, will check on that.
Here is an option:
In replace of SetProfitTarget(),use an ExitLimit() within the OnBarUpdate() method itself. Just make sure youcall this method on each bar. Theupsideis you can change the price on each bar/tick. The downside is thatthe order will not be submitted until the followingbar/tick afterentry.
private double targetPrice = 0;
private override void OnBarUpdate()
if (SMA(5)> SMA(10))
targetPrice = Math.Max(targetPrice, Low);
01-05-2007, 07:55 AM
Apparently it should work within the OnBarUpdate() method. Reviewing the code and running the test script below works.
/// Called on each bar update event (incoming tick)
protected override void OnBarUpdate()
if (Position.MarketPosition == MarketPosition.Flat || BarsSinceEntry() < 3)