Im a newbie programmer but have been able to put together a very simple strategy. My only concern is that it enters "long" positions correctly and exits "long" positions correctly.
It just doesn't perform any of the "short"entries.
Here is my strategy and I have uploaded an image of where a short should have been entered.
In red, you will see that when price crosses below a moving average enveloppe AND the price is below the longer moving average (in this case 60 week MA) then enter short.
// Condition set 1
if (CrossAbove(Close, MAEnvelopes(1.5, 3, 20).Upper, 1)
&& Close[0] > LongSMA)
{
EnterLong(DefaultQuantity, "enter long");
}
// Condition set 2
if (CrossBelow(Close, MAEnvelopes(1.5, 3, 20).Lower, 1)
&& Close[0] < LongSMA)
{
EnterShort(DefaultQuantity, "enter short");
}
// Closes the position created by entry condition 1
if (CrossBelow(Close, MAEnvelopes(1.5, 3, 20).Lower, 1))
ExitLong("enter long");
// Closes the position created by entry condition 2
if (CrossAbove(Close, MAEnvelopes(1.5, 3, 20).Upper, 1))
ExitShort("enter short");

Comment