Hi,
I'm new (just created my account), and was wondering how I can get this indicator/strat to populate buy and sell signals.
This is a long only strategy which should generate a long entry when Price closes above the 200 EMA & generate a close signal when price closes past the 50 EMA
any help would be greatly appreciated. Thanks!
Ben
I'm new (just created my account), and was wondering how I can get this indicator/strat to populate buy and sell signals.
This is a long only strategy which should generate a long entry when Price closes above the 200 EMA & generate a close signal when price closes past the 50 EMA
any help would be greatly appreciated. Thanks!
Ben
Code:
input price = close;
input length1 = 200;
input length2 = 50;
input averageType = AverageType.Exponential;
input mode = {default "Trend Following", "Reversal"};
plot Avg = MovingAverage(averageType, price, length1);
plot Avg2 = MovingAverage (averageType, price, length2);
Avg.SetDefaultColor(GetColor(0));
Avg2.SetDefaultColor (GetColor(1));
def crossAbove = price crosses above Avg;
def crossBelow = price crosses below Avg2;
def buy;
def sell;
switch (mode) {
case "Trend Following":
buy = crossAbove;
sell = crossBelow;
case "Reversal":
buy = crossBelow;
sell = crossAbove;
}
AddOrder(OrderType.BUY_AUTO, buy, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "MovAvgStratLE");
AddOrder(OrderType.SELL_AUTO, sell, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "MovAvgStratSE");