I'm using your SampleOnOrderUpdate find on the forum
you're example is based on if the market hit 4 ticks above the average price raise the stop to breakeven... but me, i want to move the stop to the moving average when the moving average is surpassing the average price, i wrote the script below.
It is working and raise my stop to the moving average but the problem is that my stop is frozen and is not following the moving average on each new bar...
if (entryOrder == null)
{
if
Here my bying condition
{
/* The entryOrder object will take on a unique ID from our EnterLong()
that we can use later for order identification purposes in the OnOrderUpdate() method. */
entryOrder = EnterLongStop(DefaultQuantity, High[0]+TickSize, "Buy");
}
}
if (Position.MarketPosition == MarketPosition.Long && SMA(SMA55)[0] > Position.AvgPrice + 1*TickSize)
{
StopMA=SMA(SMA55)[0];
// Checks to see if our Stop Order has been submitted already
if (stopOrder != null && stopOrder.StopPrice < Position.AvgPrice)
{
// Modifies stop-loss to MA - 2 ticks
stopOrder = ExitLongStop(0, true, stopOrder.Quantity, StopMA, "StopLong", "buy");
Comment