I'm looking to use a trailstop when I enter a long (or short) position placed
at a distance of 2*10 day ATR from the price I enter the position at. I want
the trailstop to move with the price if the trade goes in my favour but obviously
not move if the trade goes against me. I'm looking to backtest this strategy so I
need to fully automate it with Ninjascript. Below is what I have done so far; but
I believe that from the language "CalculationMode.Price, ATR(10)[0]*2" the trailing stop
will be set at the price which has a value of 2*10 day ATR. Instead I wish the trailstop to
be set at a DISTANCE of 2*10dayATR.
Can you assist?
Thanks,
Ciaran
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(SMA(50), SMA(100), 1))
{
EnterLong(DefaultQuantity, "");
SetTrailStop(CalculationMode.Price, ATR(10)[0]*2);
}
// Condition set 2
if (CrossBelow(SMA(50), SMA(100), 1))
{
EnterShort(DefaultQuantity, "");
SetTrailStop(CalculationMode.Price, ATR(10)[0]*2);

Comment