Hi,
I have a problem merging data within an indicator using different timeframes. The end goal is to create a simple composite of 4 different timeframes.
First, I've created 4 different versions of the same indicator by making functions for each data series (data1 / data2/ data3 /data4) - I then assign a value like +1 for positive trend and -1 for negative trend in each timeframe in a single indicator.
Next, I create charts of each timeframe in MC (by using 'insert instrument') with the shortest timeframe first (5 min / 10 min / 30 min/ daily). All charts are basically on top of each other in a single view. By using the 'base study on' tabs, I can assign each study to it's separate sub-graph by highlighting the timeframe. But that's as far as it goes. The sub-graphs show the correct data.
Using the example above of giving a value for each timeframe for positive or negative, I would like to add these values together to create a composite of the 4 time frames. However, this seems impossible to do. I cannot merge the results of the 4 time frames in to one indicator as there is no 'base study on' substitute in Powerlanguage that I am aware of.
If I can base the study on the indicator through the format tabs, so the information is correct in each of the 4 sub-graphs. Theoretically, it would seem logical that this information could be merged to create a combo or composite of the different indicator values for each time frame.
Any ideas how this might be achieved e.g. stating the timeframes within the code, as opposed to formatting in sub-graphs. I would like to turn the visual in to useable data etc.
Thanks in advance for any help !!
Merging Multiple timeframe indicators .....
- Svetlana MultiCharts
- Posts: 645
- Joined: 19 Oct 2017
- Has thanked: 3 times
- Been thanked: 163 times
Re: Merging Multiple timeframe indicators .....
Hi aconnery,
An indicator can be based on a data series (price quotes) only.
If you want to refer to different data series from an indicator, you can do it from a single indicator. There are pre-built indicators that use data from different series, for example Spread - Diff and Spread – Ratio.
If you want to apply several indicators to different charts and exchange information – you can use Global Variables.
An indicator can be based on a data series (price quotes) only.
If you want to refer to different data series from an indicator, you can do it from a single indicator. There are pre-built indicators that use data from different series, for example Spread - Diff and Spread – Ratio.
If you want to apply several indicators to different charts and exchange information – you can use Global Variables.
Re: Merging Multiple timeframe indicators .....
Hi aconnery,
I am working on something more or less similiar and maybe my approach helps:
So not shure if my observations are 100% correct, but I`m confident
Since whatever indicator information most likely will end up in a strategy, so data1, I thought I might as well programm my indicators based on data1 but adapt calculation to values of dataN. Getting that into sync was the biggest problem, but I actually think it saved me from missleading interpretations based on indicators which didnt use correct specification of dataN variables.
TJ posted:
viewtopic.php?t=6929#p35429 because using "intrabarpersist" only works, if a variable has its dataN already set when the variable is defined.
viewtopic.php?f=1&t=45508#p99082 I havent figured out the "Barstatus" part yet.
And really knowing when to use "Realtime-History Matching" or not, that screws up a lot when switching from backtest to realtime trading.
Maybe ELCollections/ADE makes things easier, but I have no clou how to use that.
Greets
Chris
I am working on something more or less similiar and maybe my approach helps:
So not shure if my observations are 100% correct, but I`m confident
Since whatever indicator information most likely will end up in a strategy, so data1, I thought I might as well programm my indicators based on data1 but adapt calculation to values of dataN. Getting that into sync was the biggest problem, but I actually think it saved me from missleading interpretations based on indicators which didnt use correct specification of dataN variables.
TJ posted:
viewtopic.php?t=6929#p35429 because using "intrabarpersist" only works, if a variable has its dataN already set when the variable is defined.
viewtopic.php?f=1&t=45508#p99082 I havent figured out the "Barstatus" part yet.
And really knowing when to use "Realtime-History Matching" or not, that screws up a lot when switching from backtest to realtime trading.
Maybe ELCollections/ADE makes things easier, but I have no clou how to use that.
Greets
Chris
Hi,
I have a problem merging data within an indicator using different timeframes. The end goal is to create a simple composite of 4 different timeframes.
First, I've created 4 different versions of the same indicator by making functions for each data series (data1 / data2/ data3 /data4) - I then assign a value like +1 for positive trend and -1 for negative trend in each timeframe in a single indicator.
Next, I create charts of each timeframe in MC (by using 'insert instrument') with the shortest timeframe first (5 min / 10 min / 30 min/ daily). All charts are basically on top of each other in a single view. By using the 'base study on' tabs, I can assign each study to it's separate sub-graph by highlighting the timeframe. But that's as far as it goes. The sub-graphs show the correct data.
Using the example above of giving a value for each timeframe for positive or negative, I would like to add these values together to create a composite of the 4 time frames. However, this seems impossible to do. I cannot merge the results of the 4 time frames in to one indicator as there is no 'base study on' substitute in Powerlanguage that I am aware of.
If I can base the study on the indicator through the format tabs, so the information is correct in each of the 4 sub-graphs. Theoretically, it would seem logical that this information could be merged to create a combo or composite of the different indicator values for each time frame.
Any ideas how this might be achieved e.g. stating the timeframes within the code, as opposed to formatting in sub-graphs. I would like to turn the visual in to useable data etc.
Thanks in advance for any help !!
Re: Merging Multiple timeframe indicators .....
Thanks for this Chris - It seems we have been walking similar paths. I will drop you a note if and when I have something that might be useful. Really appreciate your post.
Best
Best
Re: Merging Multiple timeframe indicators .....
Hello,
I am working on something similar here. Trying to use multiple Data on one chart. Also doing this from a signal and not a indicator.
When you use a Signal and send I_setplotvalue() to an indicator it looks like the value drops to zero constantly before correcting prior to a new tick coming on the chart.
The most up to date tick drops to zero then corrects then does the zero thing again. Is anyone else seeing this?
I am working on something similar here. Trying to use multiple Data on one chart. Also doing this from a signal and not a indicator.
When you use a Signal and send I_setplotvalue() to an indicator it looks like the value drops to zero constantly before correcting prior to a new tick coming on the chart.
The most up to date tick drops to zero then corrects then does the zero thing again. Is anyone else seeing this?
Re: Merging Multiple timeframe indicators .....
@joebone: "just" for the dropping value, read up on Intrabarpersist. in that context you will stumble on other things, so also read up on "realtime-history matching", "defining a dataN variable" viewtopic.php?t=6929#p35429 and "barstatus".
supposedly "maxbarsback" and "barnumber" will come in handy to get the same startingpoint for an indicator and strategy, but I havent needed that yet, the code below seems to work without.
@aconnery:
this works for me; I cant say that I like the "solution" but it actually seems quite easy....if I didnt miss anything . tested it on various timeframes and inputs(close, volume, etc.) and works fine in an indicator as well as in a strategy. the valueX vars run on data one, so with valueX[1] the higher timeframe value is carried from one data1 intervall to the next. So no Realtime-History Matching needed and hopefully no problems with backtest vs. realtime. I thought this would only work on EndOfBar but weirdly enough, it also seems to work on IOG. So I quess if I dont want to start using ELCollections/ADE, than thats it.
supposedly "maxbarsback" and "barnumber" will come in handy to get the same startingpoint for an indicator and strategy, but I havent needed that yet, the code below seems to work without.
@aconnery:
this works for me; I cant say that I like the "solution" but it actually seems quite easy....if I didnt miss anything . tested it on various timeframes and inputs(close, volume, etc.) and works fine in an indicator as well as in a strategy. the valueX vars run on data one, so with valueX[1] the higher timeframe value is carried from one data1 intervall to the next. So no Realtime-History Matching needed and hopefully no problems with backtest vs. realtime. I thought this would only work on EndOfBar but weirdly enough, it also seems to work on IOG. So I quess if I dont want to start using ELCollections/ADE, than thats it.
Code: Select all
vars:
intrabarpersist SyncedValue(0,data2),
intrabarpersist xAvgSyncedValue(0,data2);
value1 = close[0] data2;
if barstatus(2) <> 2 then value1 = value1[1];
SyncedValue = value1;
xAvgSyncedValue = xAverage(SyncedValue data2,100)data2;
value2 = xAvgSyncedValue;
if barstatus(2) <> 2 then value2 = value2[1];
xAvgSyncedValue = value2;
plot1(xAvgSyncedValue);
Last edited by Jupp25 on 09 Dec 2022, edited 3 times in total.
Re: Merging Multiple timeframe indicators .....
awesome, Thanks very much!!!
I had found some of the reading on those items but its piecemeal. Is there a sticky somewhere with all the good documentation on using multiple time frames?
I had found some of the reading on those items but its piecemeal. Is there a sticky somewhere with all the good documentation on using multiple time frames?
Re: Merging Multiple timeframe indicators .....
Hey,
seems one thing was still missing and other part could be lost. works in backtest, real-time no Realtime-History matching needed and also works with IOG.
seems one thing was still missing and other part could be lost. works in backtest, real-time no Realtime-History matching needed and also works with IOG.
Code: Select all
vars:
currentsess(0),
xAvgSyncedValue(0,data2);
currentsess = CurrentSession(0);
xAvgSyncedValue = xAverage(close data2,100);
value1 = xAvgSyncedValue;
if barstatus(2) <> 2
and currentsess = currentsess[1] //keeps values correct i.e. on daily bars(build from minutes) on days where the market closes early
then value1 = value1[1];
xAvgSyncedValue = value1;