Crossover of 2-day MA of Low
Author: anabrito
Creation Date: 2/5/2021 11:03 PM
profile picture

anabrito

#1
Hello Support Team,

I have been trying to create astrategy and was wondering if you could help me out. The strategy is described below:

Buy (at the market) when the price crosses through (touches) the 2 day moving average (calculated using the low of the previous 2 candles, not the close);
Sell (at the market) when the price crosses through (touches) the 2 day moving average (calculated using the high of the previous 2 candles, not the close)

Thanks for the help in advance
profile picture

Eugene

#2
Hi Ana,

The "New Strategy from Rules" Wizard is powerful enough to support fuzzy logic, fundamentals and external symbols - let alone such simple and natural rule as crossover. Check out our Wealth-Lab 101: Course Videos on Youtube, especially the Strategy Builder episodes. Sure you'll find out how to create this strategy yourself pretty soon (see Conditions tab > Price Action group).

Good luck!
profile picture

anabrito

#3
Thanks for the quick answer.

Unfortunatelly, the information provided on the video series werent suffice to help building that strategy.
The only options that are available on the software (at least as far as I could find), only triggers the entry on close, at the market (open of the next day) and limits that dont work for me.
What I really need is a option to buy (open a position) as soon as the price crosses or touches in another words, the average of the last two days low. And I want to close the position as soon as the price does the same thing but with the average of the last two days high.
Im attaching a example of what I mean by that.
Please see attached and if possible, please let me know if this strategy is even possible to be built on this software. thanks

profile picture

Eugene

#4
QUOTE:
buy (open a position) as soon as the price crosses or touches in another words, the average of the last two days low.

Hope this helps.

profile picture

anabrito

#5
I feel like we are getting close.
Please see attached my configurations (pictures 01-04) and let me know where I should change in order to buy and sell at the spots pointed out on the picture 05.

profile picture

Eugene

#6
You're placing an order to buy tomorrow at the 2-day SMA calculated today. But you cannot know its future value because the High and Low of tomorrow will only be available at the close. So, those arrows on your chart indicate values to be known after the market close of that day.
profile picture

anabrito

#7
I know,that's why it's not working.... but how can I put to buy today it reaches the moving average calculated by yesterday and the day before yesterdays low?
profile picture

Eugene

#8
Alerts are issued for tomorrow a.k.a. bar+1. First, a complete bar updates (can be 1-minute, 1-day, etc.) Then your strategy executes over all the bars in the chart and determines if it wants to trade on the next bar.
profile picture

superticker

#9
I had to read this discussion four times before I realized what's going on, and even now I'm not sure I truly understand it. So take my comments with a grain of salt.

Weath-Lab is a simulation (backtesting) program. If you're simulating at a Daily bar scale (which is what I do), then the actions it takes are only good at that scale--no middle of the day activity. So if there's a trigger to buy today, it will buy tomorrow at the "daily" simulation level. That it! It won't simulate "within" a Daily bar; that's not an option.

So what if you want it to take action in the middle of the day (for tomorrow) if you're simulating at the Daily bar scale? To do that, you need to step outside the WL simulation and get the Quotes window involved, which can trigger real-time alerts of its own during the day. And this operation has nothing to do with the simulation part (which is an off-line before-the-market-opens process).

So what's the easiest way to post a real-time watch list to the Quotes windows? That can be done by running Strategy Monitor. In your simulation (using rules or code), setup a BuyAtLimit order for when you want to buy the stock during the day (for tomorrow), and a SellAtLimit order for when you want to sell the stock during the day (for tomorrow). Run your Daily simulation (before market opens) with Strategy Monitor. It will create an alert that you have an upcoming buy (or sell) opportunity for the new day. Highlight that alert and press the [Monitor in Quotes Window] button so that limit order gets posted to the Quotes window. Now during the day, if that limit order price is reached, the Quotes window will create its own alert, which you can now use to trade against.
profile picture

anabrito

#10
Ok, thanks for the help Superticker, really appreciate it. So what I´m getting from this, is that I cannot backtest this strategy on wealth lab? The only possibility is to use the alert to let me know when it happens?
profile picture

Glitch

#11
While all that Superticker said is true, I believe Eugene's solution is already exactly what you asked for!

You want the system to:
"but how can I put to buy today it reaches the moving average calculated by yesterday and the day before yesterdays low?"

That's exactly what a limit order will do. It will put a buy in for today, based on the MA's that were calculated yesterday and the day before.

It's just a matter of perspective. Instead of "today" being the bar that the order executes on, we usually say "today" is the bar at which the signal was generated.

Using the limit order, your order will get filled (or not, and possibly in the middle of the bar) at the limit price calculated from the previous two day's moving average!
profile picture

anabrito

#12
It totally makes sense what you´re saying Glicth. Would you mind helping me on how to build that strategy ? I have been testing it in different markes and in different countries using some other softwares and it seems like a very profitable one but I'm struggling to build it here on Wealth Lab.
So let's image a scenario such as:

AAPL
Wednesday (02/10/2021):
O: 136.48
H: 136.99
L: 134.40
C:135.39
Thursday (02/11/2021):
O: 135.90
H: 136.39
L: 133.77
C: 135.13

So, let's say I'm planning to execute my strategy on Friday (02/13/2021)
Moving average calculated by the low of these two past days (02.10 and 02.11) = (134.40+133.77) = 134.08

So now how I would put on the Wealth lab that I would like to but at the market or limit or whatever I have to put, to EXECUTE my order as soon as the price reaches that value cited above, which is 134.08 ?


profile picture

Glitch

#13
You would use Limit orders, like this ...
CODE:
Please log in to see this code.
profile picture

Eugene

#14
QUOTE:
So now how I would put on the Wealth lab that I would like to but at the market or limit or whatever I have to put, to EXECUTE my order as soon as the price reaches that value cited above, which is 134.08 ?

Note that the code by Glitch should be run before the market opens on "Friday" i.e. after close on "Thursday".
profile picture

anabrito

#15
Glitch,

1000 times thank you ! That was exactly what I was looking for. I really appreciate the help !!!!

This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).