- ago


How it can be done with wealth lab?
0
362
Solved
8 Replies

Reply

Bookmark

Sort
Cone8
 ( 25.44% )
- ago
#1
Use AssignAutoStopTargetPrices(). If you tell me the details, I can probably quickly give you the code:
1. What kind of trade was used to enter the order?
and,
2. what is the stop logic?
0
Best Answer
- ago
#2
QUOTE:
Use AssignAutoStopTargetPrices()

Thank you, I found a topic on forum about AutoStop and AutoProfit. I need to look through it first https://www.wealth-lab.com/Discussion/AssignAutoStopTargetPrices-explained-8655
0
- ago
#3
I am using a Buy Limit Stop order to enter the position and then I want to use a trailing stop for the position - if the price of its high drops n% or more - close the position. So, this condition can happen inside one candle - candles with tall shadow. Where the price moves up and down within one candle. I have red about AutoStop and it seems that it's not the way to do it.
0
Cone8
 ( 25.44% )
- ago
#4
When using multiple Limit and Stop orders, an exit on the same bar cannot always be evaluated. For example, after you enter long with Limit a Sell at Limit target can only be filled (hypothetically) if the close is higher that the target price. However, if your stop is lower than the long limit entry, there's no problem.

But please, you cannot use a "trailing stop" on a same bar exit. There's no way to determine the order of prices (without evaluating intraday data, which is out of scope). If you need to backtest that, then you need to use intraday data.

---
I see your point. You entered on a limit, prices reached a High, and then fell back. That's actually a valid case, but trailing stops are not supported on the same bar. >> feature request!
0
Cone8
 ( 25.44% )
- ago
#5
On second thought, a trailing stop following a limit order cannot be evaluated same bar. We can’t be sure that the high was reached before or after the limit price.

Furthermore, a trailing stop can’t be evaluated on the same bar ever because the intrabar movement of prices cannot be determined.
0
- ago
#6
Thank you, for same bar it's clear, but if I want a trailing stop next bar and next bar is with tall shadow (Hight - Close) > Stop I can use bar+1 in code. But how will it work in realtime trading? Will the bar+1 logic be executed every streaming price change? Will the Close price of (bar+1) be updated realtime?
0
Cone8
 ( 25.44% )
- ago
#7
There's no way to do that in the Backtester for the same reason as before. A Trailing Stop for our backtest and trading purposes is just a stop order that moves with price, recalculated at the end of each bar. If you need that stop to move more quickly, you have to use smaller intervals. It won't move intrabar.

That said, brokers provide Trailing stop orders that move with price in real time, intrabar. It's possible to activate these order types though the API. Combined with the "Live Position" Trading Preference, I think it's viable for Auto-Trade. We'd have to study it more, but this is probably what you want to make as a feature request.
0
MIH8
- ago
#8
I appreciate the idea, but this time I am conservative. I think unless a function can not be backtested in the same way it is traded, it should not be used (exist).
0

Reply

Bookmark

Sort