How do I get incomplete daily bar

Questions about MultiCharts and user contributed studies.
Mats
Posts: 8
Joined: 19 Mar 2012
Been thanked: 1 time

How do I get incomplete daily bar

Postby Mats » 19 Mar 2012

I have an eod system that trades at the close that I want to translate to multicharts.

I have the 1 min data in data1 and daily bars in data2. I plan to have the system generate the trade at 15:59 so that it gets entered just before the close.

In order to generate the buy/sell signals I would need to calculate indicators using daily data that includes the current incomplete daily bar.

One way to do this is to record daily open, close, high during the day and then make a new array from data2 with the current daily bar added.

But, is there some easier way to do it? If there isnt, then is there some example system where it is done the hard way?

And another question - is there a way for me to use indicators that are read only in my strategies? The indicators do not have functions included.

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: How do I get incomplete daily bar

Postby furytrader » 19 Mar 2012

Depending on the types of indicators you're using on your daily chart, it's possible that you could take the indicator's value as of yesterday and adjust them to incorporate today's values, based on the current price values, before the day is closed.

For a moving average, for example, it may be fairly easy. For other indicators (like the ADX), it may be a bit harder. It depends on the indicator you're using.

As for the statement:
And another question - is there a way for me to use indicators that are read only in my strategies? The indicators do not have functions included.
What specifically do you mean here? Can you give an example?

Mats
Posts: 8
Joined: 19 Mar 2012
Been thanked: 1 time

Re: How do I get incomplete daily bar

Postby Mats » 19 Mar 2012

So, basically I am stuck doing it the hard way, right?
What specifically do you mean here? Can you give an example?
If I put an indicator on the chart, how do I access the data that it plotted? Now, if the indicator has a function that I can call, then no problem, I can just call it and have the indicator recalculated for my strategy. On the other hand, if the indicator is protected so that I cant see the source code and there is no function to call then the only way to get the indicator values would be to read it from the chart (as far as I know).

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: How do I get incomplete daily bar

Postby furytrader » 19 Mar 2012

That's right - if the code is read-only and there is no way to know what functions the indicator calls (if any), I think you'd have to read values from the chart.

Mats
Posts: 8
Joined: 19 Mar 2012
Been thanked: 1 time

Re: How do I get incomplete daily bar

Postby Mats » 20 Mar 2012

Ok, so how do I read the indicator from my code or is that not possible?

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: How do I get incomplete daily bar

Postby arjfca » 20 Mar 2012

So, basically I am stuck doing it the hard way, right?
What specifically do you mean here? Can you give an example?
If I put an indicator on the chart, how do I access the data that it plotted? Now, if the indicator has a function that I can call, then no problem, I can just call it and have the indicator recalculated for my strategy. On the other hand, if the indicator is protected so that I cant see the source code and there is no function to call then the only way to get the indicator values would be to read it from the chart (as far as I know).

- Could you print the result in the output window
- Could you read the value of the indicator from the data window

- What do you want to do with the data. Usually, indicators are calculated for each tick unless you specify to calculate it at the end of it

Good luck

Mats
Posts: 8
Joined: 19 Mar 2012
Been thanked: 1 time

Re: How do I get incomplete daily bar

Postby Mats » 21 Mar 2012


- Could you read the value of the indicator from the data window

- What do you want to do with the data. Usually, indicators are calculated for each tick unless you specify to calculate it at the end of it

Good luck
Please write me some example code that reads the value of an indicator from the data window or chart.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: How do I get incomplete daily bar

Postby JoshM » 24 Mar 2012

Please write me some example code that reads the value of an indicator from the data window or chart.
You can't read the value of the indicator from the data window or chart. In other words:
  • Indicator >> Data Window/Chart >> Print output
doesn't work since the print output can't read the Data Window or chart. This does:
  • Indicator >> Print output
If you open an indicator, say the Moving Average, you'll see this part of code:

Code: Select all

var0 = AverageFC( Price, Length ) ;
...
Plot1[Displace]( var0, "Avg" ) ;
Which signals that the 'AverageFC' function is used to calculate the MA. Now you'll know how to print the value of the MA to the output window, since in a new indicator you could write:

Code: Select all

Variables:
var0(0);

var0 = AverageFC(Close, 20);

Print("MA20 is: ", NumToStr(var0, 2));
PS: take a look at the good FAQ TJ has compiled: PowerLanguage FAQ.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: How do I get incomplete daily bar

Postby ABC » 24 Mar 2012

Mats,

I am not sure if this would work in your case, but it might be worth trying:
Dublicate the symbol you are using for Data2 in QM. You will probably have to change the exchange name, as otherwise QM will raise an error as the symbol is already present.
Other than that set it up exactly like the original symbol, only change the session close time to 15:59.
Something that might be even better is to just create a custom session template in QM and use this for your original data2 symbol on the chart.

Keep in mind that you will miss the actual close on data2 then and this might affect your indicator values, but if you can live with that it might work for you.

Regards,

Chris

Mats
Posts: 8
Joined: 19 Mar 2012
Been thanked: 1 time

Re: How do I get incomplete daily bar

Postby Mats » 24 Mar 2012

Thank you ABC for being the only one to take the time to understand the problem and propose a solution.

I do not think that it would work though since the daily bars come from the data feed supplier. IE, in daily time frame, mc/qm wouldn't download 1 min or 5 min bars and then construct the daily bar from those but instead just download the daily bars directly.

Now, I could be wrong, of course, and qm could be smart enough to construct the daily bars from a lower time frame if closing time differs from the datafeed one but I would be surprised if that was the case.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: How do I get incomplete daily bar

Postby JoshM » 25 Mar 2012

Thank you ABC for being the only one to take the time to understand the problem and propose a solution.
Seriously?

Perhaps we're both talking about a different thread here, because I see more replies in this thread than just Chris being the 'only one' to try to help you out.

Don't forget, this is a community forum and not a MultiCharts helpdesk - the other people who contributed to this thread did so in their free time and in a desire to help you out. I personally find it offensive that you downplay their efforts with your quoted comment above. I don't know if other people also find that comment misplaced, but if they do, I can imagine that your further threads get even less responses.

That the knowledgable people in this thread weren't able to give you the answer you wished for, is that a fault of them 'not taking the time' to understand you, or could it be that your wording of the question has some fuzziness and/or fault?

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: How do I get incomplete daily bar

Postby ABC » 25 Mar 2012

I do not think that it would work though since the daily bars come from the data feed supplier. IE, in daily time frame, mc/qm wouldn't download 1 min or 5 min bars and then construct the daily bar from those but instead just download the daily bars directly.

Now, I could be wrong, of course, and qm could be smart enough to construct the daily bars from a lower time frame if closing time differs from the datafeed one but I would be surprised if that was the case.
That is true, I didn't think about that. However if you build a daily bar as a minute bar i.e. 1440 Minute bar or whatever the session length is, this might work.

Regards,

ABC

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: How do I get incomplete daily bar

Postby arjfca » 25 Mar 2012

Got an idea for you

You could read your PC time clock with the function Machinetime

This function will return, as it said, the time of your machine. Make sure that you sync it periodically.

Now, knowing when you daily bar finish every day, it is easy to built a code to send your order if your machine time do it your desire time of the day

Hope it help

Martin


Return to “MultiCharts”