- ago
Hello, I'm knew here and I'm still getting to know the tool, I'm backtesting an intraday strategy and would like to implement daily trade limits based in profit and stop loss. For example, if it hits 1 profit target, it should stop trading for the day and trade only the next day, if 3 stop losses occur, it should also stop trading for that day. Is it possible to do this in Building Block?
0
233
Solved
14 Replies

Reply

Bookmark

Sort
Cone8
 ( 4.76% )
- ago
#1
Install the PowerPack Extension for a 1 trade per day condition.

For "No trades after 3 stop losses" you can try using "X Winners/Losers within Y Days" in PowerPack and then drag the "Logical Inverter" Qualifier on it.
1
- ago
#2
first of all, thanks for the support. My exit conditions are by points, both stop and profit, when I insert One Entry per day within the profit block it stopped considering the configured points. If I put it in the buy at market for example, it only makes one entry, regardless of whether it was profit or stop.
I'm trying "X Winners/Losers within Y Days" but I am not undestand how to use to limit my stopped trade and why it is necessary to inverter.
0
Cone8
 ( 4.76% )
- ago
#3
QUOTE:
If I put it in the buy at market for example, it only makes one entry, regardless of whether it was profit or stop.
Right. An entry block is the only correct place to apply this and allowing only 1 trade per day is the exact purpose of the condition.

Re: "X Winners/Losers within Y Days"
QUOTE:
... how to use to limit my stopped trade and why it is necessary to inverter.
This is a condition block that allows (or not) a signal to occur - if the conditions specified are true on the current bar, it returns "true" and allows the signal. A "false" result prevents a signal.

Usually blocks are documented in the F1 Help, but this one was overlooked until now. After investigating how it works, it wasn't programmed with intraday in mind - but we can modify it in a future PowerPack build. For example, if you specify 1 trading day, it will consider winners/losers since the last trading day at the current time-of-day. Likewise, 0 trading days would be from the current time-of-day, which would essentially make the block a no-operation.

That said and for the sake of discussion, you're looking to prevent a trade when the conditions are true, like 3 losing trades. Consequently, you need to invert the result so that when it detects 3 losing trades, it returns "false" and prevents an entry (buy or short) signal.

Imagine you configure the block like shown below. The entry condition triggers when the RSI crosses its SMA signal line. This is "ANDed" with the "X Winning/Losing" condition below it.

Ignoring the inverter, the W/L condition will allow a trade only if there has been 3 losing trades in the past 1 day, and a loser is defined by losing more than -$12. Well, this will be false and prevent trades right from the start because at the start of the day there haven't been any trades. Applying the inverter will change the "false" result to "true", allowing the trigger condition to enter trades. And, when 3 or more losers eventually occur, the inverted result will switch to false, which prevents additional entries.



After all that, however, there's no way to make the block applicable to only "today's intraday trades" without modifying the code a bit, which I'll do for the next update to the PowerPack 53.
1
Best Answer
Cone8
 ( 4.76% )
- ago
#4
Here's an example of the rule in action with PowerPack 53.
After 3 losses (red triangles) it stopped trading for the day.

1
- ago
#5
Great, I understand what is needed for the 3 daily stops, but to stop trading after 1 profit on the day? Isn't it possible then? For example, 3 trade attempts per day until 1 profit occurs.
0
Cone8
 ( 4.76% )
- ago
#6
You'd just add another (X Win/Loss) block for the Profit condition with the Inverter. Same logic - it would return true until it happened, then false to prevent more trades.

You can try it now, but the result will be in the context of the last 24-period, not just the current market day. In other words, the combination of blocks with "Within 1 Trading Day", would prevent new trades if you have 1 win or 3 losses in the 24-hour period from the last market session, which may include trades from the last market session. (That's what will be changed for intraday operation in PowerPack 53.)
1
Cone8
 ( 4.76% )
- ago
#7
Download PowerPack Build 53 now!
1
- ago
#8
I installed it today and I'm testing it but I'm not having success, first I'm testing it with profit, after 1 profit on the day, it should stop operating and only operate the next day.
And the other problem I'm having is closing open positions at a certain time so the trader doesn't go to the next day. I am sending images to illustrate.

Here are examples of operations that did not close on the same day and operations that occurred right after a profit.


0
Cone8
 ( 4.76% )
- ago
#10
1. Hmmm. I'll take another look.

2. You don't need the Time of Day rules - unless you want to load post-market data too. Just enable the Pre/Post Filter in the Strategy Settings.
0
Cone8
 ( 4.76% )
- ago
#11
It's working properly. For you it is too - except for a new trade triggered on "the exit bar". The problem is that your strategy has no real conditions - it just buys every bar. So it triggers a trade for the next bar even on a winning trade's exit bar - before the position is closed and profit can be calculated.

But that is happening only because you must have selected "Multiple Positions" at the top of the strategy. Select "Single Position" instead and you won't see that effect.

(By the way, the second set of 2 trades you highlighted are on 2 different days. But there was another case right above that on 06/05/2021, where again the next trade was triggered on the exit bar of the first winning trade that day.)
0
- ago
#13
it's configured with single position and still has this effect,you are correct, I checked, and every time this happens, the position is opened immediately after the profitable trade. Could this be a data resolution issue? My data is 5-minute OHLC

The second highlighted trade was to show that it's not closing open positions at 17:40 as configured it's carrying them over to the next day. I set start and stop times for trading to avoid the market open and stop open position near the end of the day but it not working properly too. I've already used this strategy in Metatrader and tested it this way, but I would like to test with more data.




0
Cone8
 ( 4.76% )
- ago
#14
Then I can't explain it for "Single Position". There's something else in the entry logic that you're not showing.

As for 17:40 - open a chart. Do you have 17:40 in your data?
I suspect you do not. It's because you're using a symbol WealthLab doesn't know the Market to. You need to set up a Market with the trading hours in Tools > Market & Symbols and assign that Market to that symbol.

OR, you can skip that and just use all the data by unchecking the Pre/Post Filter in the Strategy Settings.
1

Reply

Bookmark

Sort