Hey guys im creating an indicator essentially a crossover of the 6ema and the 9sma. The entry is when the ema crosses below the sma, and i want the exit to be at a percentage in price after the entry so lets say 1%. Ill show you my code so far. This is the first code ive ever written and is unfinished. How can i write exit at at a certain percent after buy?
Code:
# By C
# Moving Average
def ema6 = MovAvgExponential(close, 6);
def SMA = SimpleMovingAvg(close, 9);
def condition1 = ema6 crosses above SMA;
def buy = condition1;
def sell = ?
AddOrder(OrderType.BUY_TO_OPEN, condition = buy, price = close,100, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = “Long”);
AddOrder(OrderType.SELL_TO_CLOSE, condition = sell, price = close,100, tickcolor = Color.Red, arrowcolor = Color.Red, name = “Exit Long“);
Last edited: