Hi everyone, I have been working on improving the scripts for my conditional orders, however the conditional orders I have been working on have been filling at the market open (9:30 a.m.) using a market order, even if the customs studies I input have not executed yet. I have included images below of what I have been using for my conditional order, and I have included the script I have been trying to use as well. The intent of the script is to buy when the MACD Diff is greater than zero, and the KST is greater than the signal line. May you please help me with this? Thank you very much for your time and your help.
Code:
declare lower;
input rocLength1 = 10;
input rocLength2 = 15;
input rocLength3 = 20;
input rocLength4 = 30;
def sumRocLength = rocLength1+rocLength2+rocLength3+rocLength4;
input smaLength1 = 10;
input smaLength2 = 10;
input smaLength3 = 10;
input smaLength4 = 22;
input signal_length=9;
def ROC1 = RateOfChange(rocLength1, rocLength1, close);
def ROC2 = RateOfChange(rocLength2, rocLength2, close);
def ROC3 = RateOfChange(rocLength3, rocLength3, close);
def ROC4 = RateOfChange(rocLength4, rocLength4, close);
def RCMA1 = Average(ROC1,smaLength1);
def RCMA2 = Average(ROC2,smaLength2);
def RCMA3 = Average(ROC3,smaLength3);
def RCMA4 = Average(ROC4,smaLength4);
def KST = (RCMA1* 1) + (RCMA2* 2) + (RCMA3* 3) + (RCMA4 * 4);
def Signal_Line = Average(kst, signal_length);
def goodKST = KST > Signal_Line;
def d = MACDHistogram().diff;
def goodMACD = d > 0;
def sell1 = if goodKST and goodMACD then 1 else 0;
plot z1 = sell1;
![ZWteaJE.png](/proxy.php?image=https%3A%2F%2Fi.imgur.com%2FZWteaJE.png&hash=cc5966983183ea365105f4b65c5039a6)
![29ux9cG.png](/proxy.php?image=https%3A%2F%2Fi.imgur.com%2F29ux9cG.png&hash=a85ee7f68917af61dd4fa2ec23ba8ce7)
![2EsOoIG.png](/proxy.php?image=https%3A%2F%2Fi.imgur.com%2F2EsOoIG.png&hash=3e4fa2512797c8e8b79cc955dc35f4a7)
![PadlGW5.png](/proxy.php?image=https%3A%2F%2Fi.imgur.com%2FPadlGW5.png&hash=ff8a8f42e9c98df3a573a1468e98888a)