Bar/Scale < one minute
Author: johnesquivel
Creation Date: 6/25/2019 3:15 PM
profile picture

johnesquivel

#1
Hello,
I’m trying to learn how to code a simple strategy (ie. MA-Fast/Slow-cross) that would execute market orders in a time scale of less that one minute after the signal.
It seems the solution may be in the ‘bar’. I have read through many discussions about how/why we must use the “bar+1” versus “bar”, in-order to allow for the full bar’s calculations to complete. Since live code must use “bar+1”, my thought is to make one ‘bar’ smaller than one minute; say one second?
I have found references that only elude to this being possible:
Reference 1: In WealthLabWiki page titled: “Introductory | Bars, Loops, and Bar + 1” (http://www2.wealth-lab.com/WL5Wiki/kbBarsLoops.ashx?HL=bar,same)
In this article (in Bar Definitions, “Wealth-Lab 6 also includes support for bars that are multiples of ticks or seconds.”
Reference 2: In WealthScript QuickRef>Bars Object>Scale, it seems to mention that a bar’s Possible Scale values can be Tick, Second, etc.

Since we must allow for one full bar to pass before a trade execution, can we make each bar equal one second?
If so, how to code this?

To clarify: My goal is for the market order to execute with-in seconds of the signal even (ie. MA cross).
A follow-up thought is if this were coded with a 1-tick or 1-second bar, would it still end up with a one minute delay because WealthLab Pro’s smallest ‘scale’ is one minute, therefore, the script wouldn’t run again for a minute?
profile picture

Eugene

#2
Hi John,

Welcome to the forums.

The minimum time frame for Fidelity data (and also for Strategy Monitor's operation) is 1 minute. While you can get to execute your Strategy on Tick/Second bars with the 3rd party data provider extension like IQFeed (paid subscription required), it's important to keep in mind that Wealth-Lab is not designed for HFT (high frequency trading).

Why would you be interested in this at all?
profile picture

johnesquivel

#3
Hi Eugene,

Thanks for the quick response. I was coming to the conclusion, as you just confirmed, WealthLab is simply not designed for higher frequency trading.
I am not a coder, but I have managed to learn and figure things out with tools like WealthLab provides.
I am interested and looking for a platform/service-provider for high frequency trading. Is there a platform and/or service-provider that you recommend??
profile picture

Eugene

#4
Our forum is dedicated to Wealth-Lab (and also WealthSignals previously) software so I cannot provide suggestions on 3rd party platforms/services. Frankly speaking, HFT hasn't been my thing.

Anyway, let's focus on your goal. Could you clarify what do you mean by getting a market order to execute within seconds of the signal? The way Wealth-Lab works, you get a MA cross signal when the 1-minute bar closes, an Alert is staged, and execution already happens within seconds. What's the problem then? Or are you trying to anticipate the MA signal while the 1-minute bar is not over yet (note that such signals can and will be reversed/canceled)?
profile picture

johnesquivel

#5
I'm sorry for the typo, and I should be more specific.. should have been 'signal given', by that I meant a specified technical condition for witch to trade on, as dictated by a strategy.

One can see all the indicators update continuously, in fractions of a second, in Active Trader Pro. So if the technical event (ei. cross-over) is based on the Close, then the nano-second after that bar's close, an algorithm should send the market order.

Unfortunately, one can try a simple strategy (ei. MA-crosses) in WLP, but they loose terribly. You can see by the trade data that the only reason such strategies loose money is because they do not execute for minute(s) after the specified technical condition occurred. For example, take a MA-Fast/Slow-CrossOver or a MACD/signal-CrossOver.. For the most part this strategy is more good than bad, but since real-life market fluctuates minute to minute, this strategy gets triggered by all those small fluctuations. All those short-time-period small fluctuations create more profit losses than the longer period gains ....and only because of each trade happens more than one minute late.

It seems that WLP must first finish a bar to draw/calculate the specified indicator(s). Then on the next bar, it see's the specified CrossOver that triggers the _AtMarket order for the next bar. Then, now the open of second bar after the technical event happened, the order is sent.

If a WealthLab scripts must make the calculations for an indicator using the data at the end of a 'bar' and a market order cannot execute until the next-next 'bar', this is understandable. Then simply reducing the defined time period of a 'bar' should better synchronize the order executions with the specified technical events.
Does this make sense?

If so.. is there a way to code for a one-second bar?

Another potential killer here may be the fact that even if the script could do those three steps in say three 1-second bars... WLP only runs the script once every minute.
If this be the case, maybe whomever maintains WLP could upgrade the functionality to allow a 1-second time scale?

Again, I'm no coder but I have worked with some great ones long ago.. and I learned that, with software, anything is possible.
profile picture

Eugene

#6
Yes, WLP must finish a bar first. On the other side, an intra-bar change in the data may cancel some signals (not MA crossovers though) and considerably change the indicator's value (RSI comes to mind) by end of bar. I'd rather think of the problem in this perspective: if your strategy's success highly depends on this small fluctuation, it has too low a profit expectancy. A Monte Carlo Lab analysis may reveal that it's on shaky ground.

For WLP it has always been possible to operate on Tick/Second bar scales (see post #2) so "upgrading it to allow a 1-second scale" is not required. Neither is the ability to peek inside the tick/second bar to rush in for a signal which can get reversed. On the bright side, you can probably get there by employing the reverse-engineer approach to figure out the indicator price ahead of the (crossover) event. For a handful of indicators (MACD, SMA/EMA, RSI, Bollinger Bands) it's possible to estimate (or determine) such price ahead of the next bar and issue the crossover signal in a proactive manner. Below you'll find some informative posts on the topic which contain more links to our Knowledge Base (Wiki)*:

Creating a stop loss based on an indicator value
Determine value of indicator for next day
Identify the price at which the slope of MACD changes its sign intra-bar

For all currently implemented "RevEng..." indicators see here (except for RevEngBBandCross which isn't documented):

Pages of the Category TASCIndicators


*In case the Wiki seems down take a look here for solutions: Is Wiki down?
profile picture

Cone

#7
If you think SMA crossover can work if you knew that there would be a crossover on the next bar, then just use RevEngSMA_TC in TASCIndicators. Basically, with a very high percentage (above 90%), this indicator can predict one bar earlier when 2 moving average periods are going to cross. Here's a link with an example to demonstrate it.
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).