Here's a little snippet from a script I recently built. When the current close is the highest in the past 5 bars, a sell is indicated.
if (Close[bar] == Highest.Value(bar, Close, 5))
{
SellAtMarket(bar + 1, p, "Group1");
}
Is there some way to use a variable to record the fact that the price has reached the target price, and then trail the price upward with a stop order for each successive bar until the stop is triggered?
Thanks.
Mike
Size:
Color:
Hi Mike,
QUOTE:
Is there some way to use a variable to record the fact that the price has reached the target price,
Yes. Save it in a boolean variable and check it before executing your stop. When the Position is unloaded, reset the boolean variable to
false:
CODE:
Please log in to see this code.
Size:
Color:
Thanks, Eugene. That worked perfectly.
Mike
Size:
Color: