HiLoActivator based order for TOS


Category:
0
0

Hello Pete,

I hope you are doing well. I have tried to do study based order with TOS using HiLoActivator.

Had the settings for MKT, GTC, 15 min chart, extended hours unchecked on both sides buy and sell.

The set up was to open if it crosses above the price.  The condition was met and nothing happened. Can you please tell me what am I doing wrong?

Thank you.

 

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on April 20, 2023 11:13 am
86 views
0
Private answer

The correct topic for questions about Conditional Orders is the Strategy Guide topic so I moved your question out of "Frequently Asked Questions" and into "Strategy Guide".

The built-in chart study named "HiLoActivator" is not suitable to be used in the Conditional Order tool. The first of my two screenshots below demonstrates why. The second screenshot shows the solution.

Here is a section of code which can be used in the Study Filter of a scan or directly within the Conditional Order or Study Alert tools on Thinkorswim:

input length = 3;
def maHigh = Average(high, length);
def maLow = Average(low, length);
def state = {default init, short, long};
if (close > maHigh) {
state = state.long;
} else if (close < maLow) {
state = state.short;
} else {
state = state[1];
}
def BuyStop = if state == state.short or state != state[1] then maHigh else Double.NaN;
def SellStop = if state == state.long or state != state[1] then maLow else Double.NaN;
def buySignal = !IsNaN(SellStop) and IsNaN(SellStop[1]);
def sellSignal = !IsNaN(BuyStop) and IsNaN(BuyStop[1]);
# use this to scan/trigger orders for buy signals
plot scan = buySignal[1];
# use this to scan/trigger orders for sell signals
#plot scan = sellSignal[1];

IMPORTANT NOTE: The solution above has been further modified so that it waits until the signal bar has full closed before it triggers. Why? Because until the signal bar is closed, the signal has not completed and is subject to change. This will prevent an order or alert from being triggered before its locked in.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 20, 2023 12:42 pm