- ago
Hello,

is it possible to backtest a strategy in Wealth Labs, by adding, if market statements, for example index ETF's are above certain moving average?

Example: Breakout 20-day High

Buy on a 4% breakout on new 20-day high on an individual stock or ETF, if $SPY; $QQQ, $IWM, $MDY are above their 50 EMA, also $IWM and $MDY 10 EMA.

Sell 2 days later or when stock closes below it's 5 EMA

Stop loss below breakout day's low.



0
569
Solved
8 Replies

Reply

Bookmark

Sort
- ago
#1
Hi,

Yes, it's possible. If you haven't started your free 14-day trial, it's perfect time to dive in the world of Building Blocks:
https://www.wealth-lab.com/Software/Features/DragAndDrop

I'll leave a sample here as guidance to spark your interest. You'd need to install the PowerPack extension to get more of the required Blocks to finish the strategy.



Your index ETF condition cannot be completely fulfilled with Blocks but it's trivial to accomplish in C# code.

Feel free to explore and ask questions.
1
Best Answer
Cone8
 ( 24.56% )
- ago
#2
What part of the ETF condition can't be fulfilled? This would do it, right? (I stopped at 3 of them)

2
- ago
#3
I think, I am doing something wrong...

It supposedly should be a new 20-day high, but when I am checking my trades, it picks stocks that are nowhere near their 20-day highs.





$CRM isn't at it's 20-day high, at the time of entry.



0
- ago
#4
Ok,

I think I figured out the 20-day high filter

2
- ago
#5
Hello,

previously I wrote a question about 20-day high strategy.

Thank you, for your answers.

I subscribed

I was able to figure out the settings, however, there are still a few things I want to clarify.

1) If I want to buy a 20D high on a 20-EMA pullback, settings would be as follows, correct?



2) How do I setup a stop loss below 20EMA? I had these settings to check for 20EMA touch on a next session. However, how do I setup a stop loss if the stock keeps falling off on the same day when I bought at 20EMA



3) How do I setup a partial sell, if the stock has moved an X% amount, and I want sell 1/2?



4) In the strategy settings section, if I have set up to Daily, that means all technical indicators will be based on daily candles, right? So if I want to test an intra-day strategies I should switch to shorter time-frame, correct?



I probably will have some more questions, I will use this tread for future questions as well.

Thanks
0
- ago
#6
QUOTE:
1) If I want to buy a 20D high on a 20-EMA pullback, settings would be as follows, correct?


No, because a tradable cannot close at 20-bar high and drop below its 20-period EMA at the same time.

What you're trying to do can be coded in C# like this:
https://www.wealth-lab.com/Discussion/Set-a-stop-at-the-bottom-after-a-peak-8043
https://www.wealth-lab.com/Discussion/Open-position-after-percentage-pullback-8021

In Blocks you'd use a Qualifier or Multi-Condition Groups because your task is to combine the mutually exclusive conditions, one of which took place N bars ago. Pullback trading in Blocks deserves its own topic so I recommend starting another one.

QUOTE:
2) How do I setup a stop loss below 20EMA?


Well, you could use the "reverse-engineered SMA tomorrow close" indicator in conjunction with the Sell at Limit/Stop block like this:



QUOTE:
3) How do I setup a partial sell, if the stock has moved an X% amount, and I want sell 1/2?


Partial sells cannot be accomplished in Blocks, this is beyond their capability for now. Consider voting for this feature request:

https://www.wealth-lab.com/Discussion/Partial-Exit-Block-9204

Or you can simulate it with multiple Blocks as suggested in the forum thread.

QUOTE:
4) So if I want to test an intra-day strategies I should switch to shorter time-frame, correct?


It takes more than just selecting an intraday scale. You're going offtopic here so I'll only mention this informative blog post:

https://www.wealth-lab.com/blog/wealthlab-data-providers

For any followup questions please use another topic.
1
- ago
#8
Thank you Eugene!
1

Reply

Bookmark

Sort