New MC users may want to try this

Questions about MultiCharts and user contributed studies.
bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

New MC users may want to try this

Postby bowlesj3 » 07 Jul 2008

Special up front update which is also mentioned farther down. The solution to this problem is the "IntraBarPersist" reserve word. Also the "BarStatus" reserve word may be of some help. These commands are now described in the current documentation in the TS-Support WebSite. The history follows for those who wish to read it and also the code is below for those who wish to see what happens without the "IntraBarPersist" reserve word. If you are new and trading intraday minute bars or less you need to learn these to save yourself a lot of debugging time (maybe days of work wasted).

================================================
For someone new to MC, give this a try on your MC by creating a new study with the simple code below and putting it in your 1 minute bars (copy it in or use the attached zip of the pla file) . Here is what it does in my MC.

On the last bar on the chart with the code running on every tick, it sets testcnt to value 1, but if still on the same minute when it executes that same code on the next tick it resets testcnt back to 0. It continues to do this until that minute is finished. The print statements clearly show this. Finally when that minute is finished it leaves the value as 1 and tries to add to it again but on the second minute it sets it back to 1 with each new tick. This continues until it gets to the third minute then it holds its value at 2 and will then bring it up to the value 3 but keeps resetting it back to value 2 on each new tick during that minute.


Question? Without having to use GVs to get around this by storing the value and bring it back in on the next tick (which I have done in the past and have in a lot of my EL code) Is there a way around this so you can for example count the number of ticks that have come through in a minute?

It is very confusing for someone new to MC and probably even more confusing to a person new to MC but not new to programming. I had to sit down and figure out what is going on because it has been a while since I have created a new study and I had forgotten that MC does this. I remember now that I had worked around it by storing the values in a GV then bringing them back in on the next tick to get the value for the next addition.

Thanks,
John


Notes for trying it:

1/ It is also zipped as an attach so you can see the proper indenting.

2/ each print statement has a different marker "Here1 & here2", Here3 and Here4, Here5 and Here6. They are grouped in pairs based upon the if statements.

3/ I indented the print statements such that when you look at the print file you clearly see where a new minute is being processed.

4/ I had to create this post with the print statements going in the file C:\ALog_2.txt. My earlier attempts at this post had it going to a different directory.

Code: Select all

{A_TestCnt constantly reset back on each tick. =======================================================}


variables:
testcnt(0);
if LastBarOnChart then
begin

if testcnt = 2 then
begin
Print( File("C:\ALog_2.txt"),
" Here5", " " ,
" Time", " " ,
Time, " " ,
" TestCnt", " " ,
testcnt, " " ,
" ");
testcnt = testcnt + 1;
Print( File("C:\ALog_2.txt"),
" Here6", " " ,
" Time", " " ,
Time, " " ,
" TestCnt", " " ,
testcnt, " " ,
" ");

end;


if testcnt = 1 then
begin
Print( File("C:\ALog_2.txt"),
" Here3", " " ,
" Time", " " ,
Time, " " ,
" TestCnt", " " ,
testcnt, " " ,
" ");
testcnt = testcnt + 1;
Print( File("C:\ALog_2.txt"),
" Here4", " " ,
" Time", " " ,
Time, " " ,
" TestCnt", " " ,
testcnt, " " ,
" ");

end;


if testcnt = 0 then
begin
Print( File("C:\ALog_2.txt"),
" Here1", " " ,
" Time", " " ,
Time, " " ,
" TestCnt", " " ,
testcnt, " " ,
" ");
testcnt = testcnt + 1;
Print( File("C:\ALog_2.txt"),
" Here2", " " ,
" Time", " " ,
Time, " " ,
" TestCnt", " " ,
testcnt, " " ,
" ");

end;




end;


Attachments
Testcnt.zip
(1.29 KiB) Downloaded 217 times
Last edited by bowlesj3 on 08 Jul 2008, edited 9 times in total.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Slows EL down.

Postby bowlesj3 » 07 Jul 2008

It just occured to me as I rework the code I put together over the 3 day weekend when I did not have to worry about this problem and only today rediscovered it (ouch!), that having to save variable changes you have made to GVs then read them back in on the next tick to work with them next time around slows down EL (maybe not a lot but none the less it does). Maybe the compiler could be reworked to have special variables such as
Variable: h.MyVariable(0); {h. means old off on setting it to zero , A variable that does not get set back to zero with each new tick within the bar}

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:

Postby RobotMan » 07 Jul 2008

Hi John,

I don't use minute charts because of the volume problem, but have you tried:
"intrabarpersist" along with "barstatus"?

I'm just guessing and have not experimented using minute charts.

Bob Perry
Los Altos, CA
Attachments
BarStatus.jpg
From EL Ref pg 452
(65.83 KiB) Downloaded 919 times
intrabarpersist.jpg
From EL Ref pg 742
(40.45 KiB) Downloaded 923 times
example.txt
forum would not allow .pla files
(1.22 KiB) Downloaded 470 times

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Will read it but.

Postby bowlesj3 » 08 Jul 2008

Thanks Robot Man.

I will read the three printouts when I have my apple + coffee mental simulant during my morning startup break so I can get smart enough to understand it :-)

Up to now I have been simply saving the variable in a GV after any updates and reading it in from that GV before any updates (actually that should be worded in reverse shouldn't it). It seems simpler but the GV named lookup is doing a search and if it is not a binary search with a fast sort on entry of new elements it is going to slow things down. I asked and no one seems to know what the named GVs are doing.

In my opinion this behavior is a bug. Just because EL has a great maxbarsback function does not mean it should reset ALL variables. It should either not do this or have spacial variables that are not reset to zero at the start of every tick. Easy for me to say since I have never written a compiler. Having maintained other peoples programs which are likely much less complex than a compiler I know that it may be even harder to go in and fix this bug too. So users work around this bug and may (actually DO) waste a lot of time thinking that EL works like normal programming languages. However, applying kindness does not mean it is not a bug.
Last edited by bowlesj3 on 08 Jul 2008, edited 2 times in total.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

IntraBarPersist.

Postby bowlesj3 » 08 Jul 2008

As a followup I read over your entries RobotMan and the proper solution is in the "IntraBarPersist" reserve word (thanks once again - you solved it).

I went back to the manuals I picked up on the TS-Support Website last August 2007. I also went back to the reserve word lists I had on my hard drive. I searched them and could not find this reserve word. The old TS4.0 manual also did not have it. I had read these manuals front to back and first experienced this problem last August/September. Someone I guess went through what I went through and complained and they put the same idea in (special variables that do not get set back at the start of a new tick within the current intraday bar being built). Then I checked the current TS-Support Website manuals and this reserve word is in there now. So I guess I have on my ToDo list another read through to see if there are any other commands out there I can use which are not in my old documentation. I will down load them because I like to read offsite (can't read when prices are coming down to my charts).

Great forum.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

The code results with the IntraBarPersist

Postby bowlesj3 » 08 Jul 2008

Using MC2.1.999.999 I changed the above code to have the IntraBarPersist reserve word. Now as you can see the minute times for all prints are showing it is the same intraday bar and the count is being incremented. Thanks to TJs help I can put the text out there indented properly too.

Code: Select all

Here1 Time 921.00 TestCnt 0.00
Here2 Time 921.00 TestCnt 1.00
Here3 Time 921.00 TestCnt 1.00
Here4 Time 921.00 TestCnt 2.00
Here5 Time 921.00 TestCnt 2.00
Here6 Time 921.00 TestCnt 3.00
Here is what happens without the "IntraBarPersist".

Code: Select all

Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here1 Time 927.00 TestCnt 0.00
Here2 Time 927.00 TestCnt 1.00
Here3 Time 928.00 TestCnt 1.00
Here4 Time 928.00 TestCnt 2.00
Here3 Time 928.00 TestCnt 1.00
Here4 Time 928.00 TestCnt 2.00
Here3 Time 928.00 TestCnt 1.00
Here4 Time 928.00 TestCnt 2.00
Here3 Time 928.00 TestCnt 1.00
Here4 Time 928.00 TestCnt 2.00
Here3 Time 928.00 TestCnt 1.00
Here4 Time 928.00 TestCnt 2.00

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:

Postby RobotMan » 08 Jul 2008

Hi John,

Glad it worked! A total guess on my part.

I didn't know MC had online docs, so I went to d/l ( http://www.tssupport.com/multicharts/tutorials/ ) and found that the MC User Guide was transfered from .chm to .pdf and opens and works fine. I'm not sure why the 2 .chm files are listed (multicharts.chm, powerlanguage.chm), because when I try to open them, nothing except the table of contents shows up. (see attached) I am assuming they are obsolete artifacts.
But it is nice to see .pdf documentation that I can use.

Bob Perry
Los Altos, CA

PS - am enjoying the current "energy" discussion on the O-list. I really wonder what the future will bring.
Attachments
PLE Guide02.jpg
(183.64 KiB) Downloaded 910 times
PLE Guide01.jpg
(99.97 KiB) Downloaded 904 times

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 08 Jul 2008

H Bob,

I was able to view the .CHM format help at the following URL. The commands are there. I just checked and it is the same URL. I also went into the second one on the llist again and the commands are there properly. I tried the first one and it too is all there. If you can't get them let me know and I will save them and forward them. I tried going in not logged in but it is different. You get a save menu and can not see them.

http://www.tssupport.com/multicharts/tutorials/

O-List, are you referring to the Omega-list. What is the topic? It is Oil Prices and Supply or Omega Research's TS?

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:

Postby RobotMan » 08 Jul 2008

This was my problem:
http://geekswithblogs.net/evjen/archive ... 83567.aspx

I opened "properties" and clicked "unblock" and now it is ok.

- the Omega List - I was referring to the thread about "stock to buy- GPRE" and about how the energy crisis seems to be more about politicians' incompetency and situational ethics than reality. Many of the "great ones" on the list have chimed in with some very interesting observances. I thought you might be following along is all.

Bob Perry
Los Altos, CA

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 08 Jul 2008

Hi Bob,

Yah, I saw that post. It was/is active. I was just thinking on the weekend that the OmegaList is more active than this forum. I get so busy that at times I never look at those posts. Just today, I saw that the former press secretary of George Bush released his book. He was on an interview on one of our local stations in the news. Here is the URL to that TV interview. Maybe you have not heard of that book yet. He had very interesting things to say. Life gets complex. Oil prices rising is good and bad. It will lead people to low emission cars on the good side. On the bad. Not sure. It is a little scary. I started getting worried about global warming 1998 when I was using TS4.0.

http://www.ctv.ca/servlet/ArticleNews/s ... /20080528/

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Learned someing about Text_New

Postby bowlesj3 » 08 Jul 2008

Gee, with this new IntraBarPreserve command I learned something about Text_New that I did not know. It only holds if it is placed on the last bar of the tick. All variables are preserved.


This code causes the text to flash then disappear.

Code: Select all

if LastBarOnChart then
begin
if MyCount = 0 then
begin
MyCount = MyCount + 1;
TimeLoc = MinutesToTime(TimeToMinutes(Time) + 3);
value1 = Text_New(Date,TimeLoc,Close,Numtostr(MyCount,0));
end;
end;
This code does not put it on until tha last tick but it holds.

Code: Select all

if LastBarOnChart then
begin
if MyCount = 0 and BarStatus = 2 then
begin
MyCount = MyCount + 1;
TimeLoc = MinutesToTime(TimeToMinutes(Time) + 3);
value1 = Text_New(Date,TimeLoc,Close,Numtostr(MyCount,0));
end;

end;

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 08 Jul 2008

Gee, trying to use this IntraBarPersist forces you to learn some of the other commands of EL better and what is actually going on under the hood.

To get the Text to stay out front immediately once this system is turned on then hold it after the bar is done and to be able to move it after that without constantly executing the TL_New command requires the code below.

It makes me scratch my head and wonder how my systems were working so well without this command.

I am writing a study where I have to move text on the screen after the fact Manually and it is to be used as input into the system itself. Without the preserve it was moving it back on me until one full minute is complete. Now I understand why. Because the TL_New is still putting it out there over an over with immediate delete after the placement and doing this until the end of the minute. Only after that first minute is complete could I move the text.

No more posts. If anyone wants to dig in, have fun.

Code: Select all

{when you use IntraBarPersist you are forced to get a better understanding of some of the commands. Try this code, and look at what it does very closely.}

variables:
IntraBarPersist DateLoc(0),
IntraBarPersist TimeLoc(0),
IntraBarPersist CloseLoc(0),
IntraBarPersist MyCount(0),
IntraBarPersist TextID(0),
IntraBarPersist BarSize("");

if LastBarOnChart then
begin
if MyCount = 0 then
begin
TimeLoc = MinutesToTime(TimeToMinutes(Time) + 10);
if BarStatus < 2 then
begin
{
Here it puts out a new one on every tick so it gets
blanked out on the next tick
}
value1 = Text_New(Date,TimeLoc,Close,Numtostr(MyCount,0));
value2 = text_setstring(Value1,NumToStr(Value1,0));
end
else
begin
{
Here it puts out a new one on every tick again but since
it is the last tick it can stop putting out new ones
You will notice that it stops following the close for
a little while but it is still out front
}
TextID = Text_New(Date,TimeLoc,Close,Numtostr(MyCount,0));
value2 = text_setstring(TextID,NumToStr(TextID,0));
MyCount = MyCount + 1;
end;
end;
if MyCount > 0 then
begin
MyCount = MyCount + 1;
if MyCount = 20 then
begin
{
This command is to prove that it has held it by moving
it back at tick 20 while the next bar is still being built.
}
TimeLoc = MinutesToTime(TimeToMinutes(Time) - 10);
value1 = Text_SetLocation(TextID,Date,TimeLoc,Close);
end;
end;
end;


Return to “MultiCharts”