i haven't used OCO code, but i'm guessing it is similar to a scan code.
i think tos expects the code to have a true or false plot value, not a number.
problems,
..you are trying to use a study to determine a true/false situation, but don't have any true/false outputs (plots)
..this study is set up to be an upper chart study.
..has 4 plots. there should be just 1 plot
..all the plots have number values, not true/false (not 0 or 1)
fix
..disable all outputs , plots, AssignPriceColor() , labels, bubbles, ...
..change all the plots to def. then create 1 plot formula that will be true or false
..figure out what condition you want this oco thing to trigger on and make a new plot formula for it.
--------------------------
i made a lower chart study for you to experiment with.
it plots a spike at 1 when plot z is true, when concavity is different from the previous bar.
..i copied a formula and replaced data with 1 and double.nan with 0.
..(true is the same as 1, false is 0)
plot z = if concavity[1] != concavity then 1 else 0;
Code:
# OCO_code_not_working_00_lower
#https://usethinkscript.com/threads/study-based-oco-trouble.14592/
#Study-based OCO trouble
#Issue: Conditional study-based OCO order is not executing at all
declare lower;
input Quantity = 2;
input numberOfBars = 20;
input AvgType = AverageType.HULL;
input STAtrMult = 2.75;
input nATR = 12;
def Point = (Quantity / TickSize()) * TickValue();
def day = GetDay();
def PMfirstBar = day != day[1];
def PMOpen = if PMfirstBar then open else PMOpen[1];
def currentDay = GetLastDay() == GetDay() and GetLastYear() == GetYear();
def PMO = if currentDay then PMOpen else Double.NaN;
def okToPlot = IsNaN(close[-numberOfBars]);
input average_type = AverageType.HULL;
input length1 = 55;
input price = close;
input signalSource = {default concavity, direction};
input paintbars = no;
def data = MovingAverage(average_type, price, length1);
#plot data = MovingAverage(average_type, price, length1);
#data.SetPaintingStrategy(PaintingStrategy.LINE);
#data.SetDefaultColor(Color.CYAN);
#data.SetLineWeight(3);
#data.HideTitle();
#data.HideBubble();
def direction = if data[1] < data then 1 else -1;
#def slope = reference LinearRegressionSlope(data, Max(RoundDown(length / 10,0), 2));
def slope = reference LinearRegressionSlope(data, Sqrt(length1));
def concavity = if slope > slope [1] then 1 else -1;
#data.AssignValueColor(if concavity > 0 and direction > 0 then Color.GREEN else
# if concavity > 0 and direction < 0 then Color.DARK_GREEN else
# if concavity < 0 and direction < 0 then Color.RED else
# Color.DARK_ORANGE);
def ss = if signalSource == signalSource.concavity then concavity else direction;
#AssignPriceColor(if !paintbars then Color.CURRENT else if ss > 0 then Color.GREEN else Color.RED);
def MA_Max = if data[-1] < data and data > data[1] then data else Double.NaN;
#plot MA_Max = if data[-1] < data and data > data[1] then data else Double.NaN;
#MA_Max.SetDefaultColor(Color.WHITE);
#MA_Max.SetPaintingStrategy(PaintingStrategy.SQUARES);
#MA_Max.SetLineWeight(5);
#MA_Max.HideBubble();
#MA_Max.HideTitle();
def MA_Min = if data[-1] > data and data < data[1] then data else Double.NaN;
#plot MA_Min = if data[-1] > data and data < data[1] then data else Double.NaN;
#MA_Min.SetDefaultColor(Color.WHITE);
#MA_Min.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
#MA_Min.SetLineWeight(5);
#MA_Min.HideBubble();
#MA_Min.HideTitle();
#def turning_point = if concavity[1] != concavity then data else Double.NaN;
#plot turning_point = if concavity[1] != concavity then data else Double.NaN;
#turning_point.SetLineWeight(3);
#turning_point.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS);
#turning_point.SetDefaultColor(Color.WHITE);
#turning_point.HideBubble();
#turning_point.HideTitle();
plot z = if concavity[1] != concavity then 1 else 0;
#