JeffryBatista
Member
In this simple Strategy, I need help adding 3 things. An Addorder code that sells any open positions before market close, a way to tell my strategy to only take positions when the market is open and don't take any positions after market close. I will leave the code down below. Any help given is truly appreciated.
Code:
#200SMA
input price = close;
input length = 200;
input displace = 0;
plot SMA = Average(price[-displace], length);
#ORDERCODE
def quantity = 100;
def Buy = price >= SMA;
def Sell = price <= SMA;
AddOrder(OrderType.BUY_TO_OPEN, Buy, price, quantity, name = "Buytoopen");
AddOrder(OrderType.SELL_TO_CLOSE, Sell, price, quantity, name = "Selltoclose");