Hello, scripters. I hope you're all well.
I'm hoping to get a little guidance on my first strategy. It's a simple moving-average cross-over strategy.
I mimicked a couple of different things, including the default strategies found in TOS. However, I can't seem to make it trigger any transactions. I figured that I'm missing something obvious and thought I should ask the experts...
I'm working on a simple cross-over strategy. Here's what I've got so far...
I can get the EMAs to plot but I cannot get any sales. Do you think someone can help with this?
Thank you in advance!
I'm hoping to get a little guidance on my first strategy. It's a simple moving-average cross-over strategy.
I mimicked a couple of different things, including the default strategies found in TOS. However, I can't seem to make it trigger any transactions. I figured that I'm missing something obvious and thought I should ask the experts...
I'm working on a simple cross-over strategy. Here's what I've got so far...
Code:
#INPUTS
input price = close;
input tradeSize = 2;
input fastLength = 5;
input slowLength = 12;
input averageType = averageType.EXPONENTIAL;
#def FastMA = MovingAverage(averageType, price, fastLength);
#def SlowMA = MovingAverage(averageType, price, slowLength);
#DEFINITIONS
def buySignal = fastLength crosses above slowLength;
def sellSignal = fastLength crosses below slowLength;
def sellShortSignal = fastLength crosses below slowLength;
def buyToCover = fastLength crosses above slowLength;
#SALES
AddOrder(orderType.BUY_TO_OPEN, buySignal, open[-1], tradeSize, Color.CYAN, Color.CYAN);
AddOrder(orderType.SELL_TO_CLOSE, sellSignal, open[-1], tradeSize, Color.GREEN, Color.GREEN);
AddOrder(orderType.SELL_TO_OPEN, sellShortSignal, open[-1], tradeSize, Color.ORANGE, Color.ORANGE);
AddOrder(orderType.BUY_TO_CLOSE, buyToCover, open[-1], tradeSize, Color.BLUE, Color.BLUE);
#PLOT
plot FastMA = MovingAverage(averageType, price, fastLength);
plot SlowMA = MovingAverage(averageType, price, slowLength);
FastMA.SetDefaultColor(GetColor(1));
SlowMA.SetDefaultColor(GetColor(2));
I can get the EMAs to plot but I cannot get any sales. Do you think someone can help with this?
Thank you in advance!