Hi everyone,
The script below triggers when the stock price goes below the market open (9:30 a.m.) price for the current day and when the MACD Diff is negative. The script below triggers after the candle closes. Is there a way to adjust the script so that the script triggers as soon as the MACD Diff crosses below zero instead of waiting until after the candle closes? Thank you very much for your time and your help.
The script below triggers when the stock price goes below the market open (9:30 a.m.) price for the current day and when the MACD Diff is negative. The script below triggers after the candle closes. Is there a way to adjust the script so that the script triggers as soon as the MACD Diff crosses below zero instead of waiting until after the candle closes? Thank you very much for your time and your help.
Code:
input sell_percent_gain = 0.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 d = MACDHistogram().diff;
input trigger_on_all_prices_below_stop = yes;
def sell1 = if (daystart or trigger_on_all_prices_below_stop) and pergain <= sell_percent_gain and d < 0 then 1 else if d < 0 and pergain crosses below sell_percent_gain then 1 else 0;
plot z1 = sell1;
![huKNuLL.jpeg](/proxy.php?image=https%3A%2F%2Fi.imgur.com%2FhuKNuLL.jpeg&hash=093ab536da9fb87518e8a9905ce9c4db)
![zWC2azd.jpeg](/proxy.php?image=https%3A%2F%2Fi.imgur.com%2FzWC2azd.jpeg&hash=02cc58c5dc362c8c8842d40b884f0e1b)
Last edited by a moderator: