My SCO not triggering when expected. Can't figure out why?

Mocnarf1

Member
I have a study based Conditional Order that fails to trigger when I can see on the chart that it should have triggered.
What would cause the problem?
Here's details:

[image] [/image]

MyBuySell_Trend_Strategy
Code:
def buy = 
open < SimpleMovingAvg("length" = 81)."SMA"[0]
and TrendPeriods("fast length" = 21, "slow length" = 42) [0] < 0
and TrendPeriods("fast length" = 21, "slow length" = 42)[3] < 0 
and TrendPeriods("fast length" = 21, "slow length" = 42)[4] > 0
;

def sell =
TrendPeriods("fast length" = 21, "slow length" = 42) > 0
and TrendPeriods("fast length" = 21, "slow length" = 42)[13] > 0 
and TrendPeriods("fast length" = 21, "slow length" = 42)[14] < 0
;

def buysignal = buy;
def sellsignal = sell;
AddOrder(OrderType.BUY_TO_OPEN, buysignal, name = "Buy", tickcolor = Color.DARK_RED, arrowcolor = Color.RED);
AddOrder(OrderType.SELL_TO_CLOSE, sellsignal, name = "Sell", tickcolor = Color.GREEN, arrowcolor = Color.GREEN);

MyBuy_Trend Study
Code:
plot condition = 
open < SimpleMovingAvg("length" = 81)."SMA"[0]
and TrendPeriods("fast length" = 21, "slow length" = 42) [0] < 0
and TrendPeriods("fast length" = 21, "slow length" = 42)[3] < 0 
and TrendPeriods("fast length" = 21, "slow length" = 42)[4] > 0
;
MySell_Trend Study
Code:
plot condition = 
TrendPeriods("fast length" = 21, "slow length" = 42) > 0
and TrendPeriods("fast length" = 21, "slow length" = 42)  from  13 bars ago > 0 
and TrendPeriods("fast length" = 21, "slow length" = 42) from 14 bars ago < 0
;
 
Solution
I have a study based Conditional Order that fails to trigger when I can see on the chart that it should have triggered.
What would cause the problem?
You didn't mention which of the above scripts did not fire so it isn't possible to comment on where the issue might be.
1. Are you stuffing your whole code into the Order Editor, or have you saved the study in the study tab, and you are referencing the study with the condition wizard?

2. Given that the Conditional Order widget is identical to the Chart alert window, try setting up your order as a chart alert (right-click anywhere on your chart and then scroll down to create alert).

If it fires as a chart alert but not on your order, it is a ToS support issue.
If it does not fire...
I have a study based Conditional Order that fails to trigger when I can see on the chart that it should have triggered.
What would cause the problem?
You didn't mention which of the above scripts did not fire so it isn't possible to comment on where the issue might be.
1. Are you stuffing your whole code into the Order Editor, or have you saved the study in the study tab, and you are referencing the study with the condition wizard?

2. Given that the Conditional Order widget is identical to the Chart alert window, try setting up your order as a chart alert (right-click anywhere on your chart and then scroll down to create alert).

If it fires as a chart alert but not on your order, it is a ToS support issue.
If it does not fire on the chart alert, you have a script error.
 
Last edited:
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

It was a Buy Script. The sequence is Buy-Sell no sell orders trigger until a Buy Order has filled.
I like the idea of the Chart alert. Never used one before but I'll give it a try. Curious thing is
occasionally a Buy will trigger even though the chart Buy signal did not trigger. Frustrating...

It just happened as I was writing this reply: TOS Bot when the Conditional Order' Study was not
true. Here's the image that shows it.

[image] [/image]
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
647 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top