Tomahawk6117
Member
Hi @halcyonguy, you were very helpful in starting the code below for me, thank you very much. I have made some edits so that it sells when the price crosses below a 20% loss from the market open price. May you please tell me, is there a way to edit the code so that the stock will sell at the close of any candle where the price is below 20% from the market open, even if it has not just crossed this price? Thank you very much for your time and your help, I really appreciate it.
Code:
input sell_percent_gain = -20.0;
input price1 = close;
input start = 0930;
def daystart = secondstillTime(start) == 0;
def dayopen = if daystart then open else dayopen[1];
def daydiff = round(price1 - dayopen,2);
def pergain = round(100*daydiff/dayopen,1);
def sell1 = if daystart and pergain < sell_percent_gain then 1 else if pergain crosses below sell_percent_gain then 1 else 0;
plot z1 = sell1;
z1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
z1.SetDefaultColor(Color.red);
z1.setlineweight(3);
z1.hidebubble();
Last edited: