I am trying to create a study-based conditional order and am finding that ToS thinks the study meets the conditional requirements, regardless of what I enter as the trigger threshold. Here is the script I'm trying to use:
That study creates the following chart, so it looks like the script is working as it should:
My process for creating the conditional order is to create the order (in this case the 18Mar22 IWM 175/214 strangle), click on the gear icon next to the exchange selection, then under the Conditions section of the page I select IWM for the symbol and then select Edit Study for the method which brings me to the Study Order Condition window. I change the aggregation to 1-minute, add my study and verify the input are correct, fill out the trigger condition, and make sure the AlertValue looks reasonable:
After I click OK I am back at the Order Rules window and it looks like this:
I click Save and then send the order. Within seconds the order is "WORKING" instead of "WAIT COND", despite the Alert value being ~1.88 and my trigger being "less than or equal to 1.30". I tried making it greater than just in case there some weird inverse comparison going on, but it still went to "WORKING" within seconds. What is going on here? Am I missing something? Is this an issue with my script, or the order, or ToS, or me?
Code:
input dura = 10;
input agg = AggregationPeriod.MIN;
input PutStrike = 175;
input CallStrike = 214;
input underlyingEXP = ".IWM220318";
def na = double.nan;
input show_option_plots = yes;
def call_mark1 = close(Concat(underlyingEXP, Concat("C", CallStrike)), period = agg, priceType = PriceType.MARK);
def call_mark2 = if isnan(call_mark1) then call_mark2[1] else call_mark1;
def put_mark1 = close(Concat(underlyingEXP, Concat("P", PutStrike)), period = agg, priceType = PriceType.MARK);
def put_mark2 = if isnan(put_mark1) then put_mark2[1] else put_mark1;
plot avg = Average((call_mark2+put_mark2),dura);
avg.setdefaultcolor(color.magenta);
plot cmark = if show_option_plots then call_mark2 else na;
cmark.setdefaultcolor(color.blue);
plot pmark = if show_option_plots then put_mark2 else na;
pmark.setdefaultcolor(color.red);
That study creates the following chart, so it looks like the script is working as it should:
My process for creating the conditional order is to create the order (in this case the 18Mar22 IWM 175/214 strangle), click on the gear icon next to the exchange selection, then under the Conditions section of the page I select IWM for the symbol and then select Edit Study for the method which brings me to the Study Order Condition window. I change the aggregation to 1-minute, add my study and verify the input are correct, fill out the trigger condition, and make sure the AlertValue looks reasonable:
After I click OK I am back at the Order Rules window and it looks like this:
I click Save and then send the order. Within seconds the order is "WORKING" instead of "WAIT COND", despite the Alert value being ~1.88 and my trigger being "less than or equal to 1.30". I tried making it greater than just in case there some weird inverse comparison going on, but it still went to "WORKING" within seconds. What is going on here? Am I missing something? Is this an issue with my script, or the order, or ToS, or me?