smoss611
New member
So I've been trading a while, and I wanted to teach myself thinkScript. I have been tinkering with the code and using snippets from other sources, but I finally wrote my own very basic from scratch.
After deciphering the various errors, I finally got it to work. (Sort of)
I can get the script entered with no errors; however, I do not show any P/L at the bottom of my screen. It shows with other copied scripts, so I'm missing something basic.
I'm sure this is a bit of a softball, but thanks in advance.
After deciphering the various errors, I finally got it to work. (Sort of)
I can get the script entered with no errors; however, I do not show any P/L at the bottom of my screen. It shows with other copied scripts, so I'm missing something basic.
I'm sure this is a bit of a softball, but thanks in advance.
Code:
# Trial 1
def SMAprice = close;
def SMAfast = 50;
def SMAslow = 200;
# MACD
def fastLength = 12;
def slowLength = 26;
def MACDLength = 9;
def MACDAverageType = AverageType.EXPONENTIAL;
def ZeroLine = 0;
def buy = fastLength[1] crosses above slowLength[1] and fastLength[1] < ZeroLine[1] and SMAfast > SMAslow;
addOrder(OrderType.BUY_AUTO, buy, name = "CrossoverBUY, tradeSize = 100");
def sell = SMAfast crosses below SMAslow or fastLength crosses below slowLength;
addOrder(OrderType.SELL_TO_CLOSE, close, name = "CrossoverExit", tradeSize = 100);