Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
That's a rough idea, you might want to use less rounding (e.g. use the Round2TickSize function) or run with different event settings but something like that should do enough. There are other ways but I like simple. (Do excuse any spelling/syntax/sematic errors, I'm only on a ChromeBook.)
ed: Just a thought, I think there are CrossAbove/CrossBelow/etc functions that could be useful in this area
Trying to summarize some of the essentials of coding multi-timeframe indicators...
Options
There are three options
(1) loading secondary bar series and calculating indicator values from secondary bars
(2) calculating composite bars from primary bars …
Your first example: In the case of an SMA, you can simply tweak the indicator by adapting the period. The 5-period SMA of a 20 minute chart comes very close to a 10-period SMA of a 10-minute chart. Therefore for your first example you do not need to create any indicator that loads multiple bar series.
Your second example: This question is not clearly put, because if you use 20 min and 30 min bars, they will sometimes have a common close and they will sometimes not have a common close. In this case I would use a 10 min chart and compare the 3-bar high to the 2-bar high, or the 3-bar low to the 2-bar low. This approach beats any approach using 20 and 30 min bars.
Below is a sample chart of what can be done without adding a secondary bar series.
-> the first chart shows genuine MACDs which are calculated from composite bars (composite bars are created from primary bars, something which is possible for minute, tick and volume bars)
-> the second chart shows tweaked MACDs, which have the timeframe problem resolved by adapting the indicator lookback periods
Of course there is a small difference between the genuine and the tweaked indicators. Which one would you prefer?
Thanks Fat Tails. The time periods were just examples to see what could be done and to make it a bit easier for me to ask the questions. I also have an interest in comparing different fractals on charts that are not time based.
One of the reasons that coding multi timeframe indicators is so confusing is that, for historical data, only one tick is provided per bar. Let's see how this plays out in an example with a multi time frame indicator on a one minute chart. The primary price series, Bars[0], is a one minute bar series that prints to the chart, and the Added secondary price series, Bars[1], is a one second price series of the same instrument. As shorthand, the BarsInProgress property will be abbreviated BIP.
Once per minute, a bar of the primary series will print to the chart. When that bar prints, BIP equals zero and FirstTickOfBar will be true for the primary bar series. However, the fact that the bar has a high, low and close as well as an open, clearly shows that the appearance of this bar was actually triggered by its completion, not its commencement. So, for historical data, what is called "FirstTickOfBar" is actually the LAST tick of the bar.
The very next price tick will be from the secondary series, BIP will be 1, and Closes[1][0] and Times[1][0] will be the same as the most recent Closes[0][0] and Times[0][0], since this is the last one second period within the primary bar, Bars[0][N]. Anything calculated from this tick will correctly plot at the same place in the horizontal scale as CurrentBars[0][N].
Now the problems begin. Bars[0][N] is FINISHED. The next 60 ticks of the secondary series belong to Bars[0][N+1], not to Bars[0][N]. However, Bars[0][N], is THE Current Bar as far as the chart is concerned; Bars[0][N+1] does not even exist yet. It won't show up for one more minute, until it ENDS. So any data derived from these ticks will erroneously be plotted to the most recent bar on the chart, Bars[0][N].
Understanding how to correct for this is one of the major requirements for properly coding multi time frame, or multi instrument, indicators.
"If we don't loosen up some money, this sucker is going down." -GW Bush, 2008
Lack of proof that something is true does not prove that it is not true - when you want to believe. -Humpty Dumpty, 2014
The greatest shortcoming of the human race is our inability to understand the exponential function. Prof. Albert Bartlett
Any thoughts out there on using SuperSmoothers based on time frames other than those on the chart, such as shown here?
The high and low pass limits of the MESA Stochastic used to be hard coded at 10 and 48, but on this particular chart they are 12 and …
"If we don't loosen up some money, this sucker is going down." -GW Bush, 2008
Lack of proof that something is true does not prove that it is not true - when you want to believe. -Humpty Dumpty, 2014
The greatest shortcoming of the human race is our inability to understand the exponential function. Prof. Albert Bartlett
A question, I try to use the VisualEMA in a strategy, build with the Strategy Wizard and I would like that the VisualEMA under "Rissing" paints the background. Right now it paint's only some single lines, what do I have to do, that it paints correctly?
The VisualEMA calculates node values according to the selected period for its internal bars and then interpolates the distance between the current value and the node. Interpolating means that it is repainting back to the last node. Repainting indicators cannot be accessed via a strategy created with the strategy wizard. However, it could be accessed via a manually coded strategy, as the number of bars that are currently repainted are exposed and can be accessed.
If you wish to access it with the strategy wizard, then you need to use the indicator in strategy mode (NOT: visual mode). In strategy mode the indicator paints a step function. Everytime a secondary bar closes the VisualEMA follows with a new value. I do not know whether you can define a rising state and a falling state for a step function with the strategy wizard. It is definitely easy to achieve, if you code manually.
Please be aware that the Visual EMA repaints in visual mode - it repaints back to the prior node - and therefore the slope derived from a new value will only be available in real time when the secondary bar has closed.
I am setting up a strategy that uses an EMA/Cross for an entry of one timeframe and uses an EMA/Cross of another timeframe reversing for my exit/stop. Could this indicator be used in a strategy for this? And if not, would you kindly point me in the right direction of another Ninja indicator that can accomplish this if you know of one.
I guess I am basically looking for an alternative option of the general stop/loss by using another EMA Cross on a different timeframe than the primary entry for my exit.