If Barstatus = 0 then Begin... Not always detected

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

If Barstatus = 0 then Begin... Not always detected

Postby arjfca » 09 Mar 2012

Hello

I got a process that as to be done at the beginning of a bar
- Capture the last High, Low
- Capture the time: ending time end time[1] Starting time

These value are then transmit to my Excel sheet to be process and fire if needed an order.

Problem is BarStatus = 0 is once in a while not detected and data are not sent for this bar. It may occur while system is occupied with a voice message. I will turn of the voice, but is there other way to insure that all Barstatus = 0 is detected.

I did work with BarStatus[1] = 2, but doing so, I don't have the ending time of the actual starting bar

Martin

Code: Select all

if barstatus = 0 then begin
BarCompleted = "BC";

// Now, Format the time for the GAD & GTA
Datetimestring = FormatTime("HH:mm:ss", ELTimetodatetime_s(Time_s[1]));
EndDateTimeString = FormatTime("HH:mm:ss", ELTimetodatetime_s(Time_s));

//Format the date for the GAT & GTA
GAD_Str = Leftstr(Text(date[1] + 19000000),8); //good afterdate
GTD_Str = Leftstr(Text(date + 19000000),8); // good til date

GAD_STR = Gad_Str + spaces(1) + DateTimeString;
GTD_STR = GTD_Str + spaces(1) + EndDateTimeString;

//print (gad_Str, spaces(5), gtd_Str);

LastbarString = numtoStr(Open[1],5 )+ comma + NumtoStr(High[1],5) + comma + NumToStr(Low[1],5) + comma + NumToStr(Close[1],5)+ comma +
NumToStr(LSL1,5) + comma + NumtoStr(lsl2,5) + comma + NumToStr(lsh1,5) + comma + NumToStr(lsh2,5) + comma +
GAD_Str + comma + GTD_Str ;

Lastbarstring = lastbarstring + comma + exittimestring + comma + exitdatestring + Barcompleted;

//print ( "sbook ", Sbook," ", ssheet," ", lastbarstring);
xlo.Text(Sbook,sSheet,"LastBarString",LastBarString);
LastBardone = false;
print (time_S:0:0, " ", lastBarString);

end;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: If Barstatus = 0 then Begin... Not always detected

Postby TJ » 09 Mar 2012

try

Code: Select all

if T > T[1] then begin

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

Re: If Barstatus = 0 then Begin... Not always detected

Postby arjfca » 09 Mar 2012

Hello TJ

No it don't work in my situation. My problem is with the initial loading of the chart. I truly need to bypass all calculation from MC from bar 1 to the last created bar

Problem occur because my code is sending data to Excel. This is a slow process. And each bar that MC see while loading the indicator is seen as true for T > T[1]. So, for each bar MC is sending data to Excel

If I could bypass the loading process, then it should work

I did try with If T > T[1] and LastBarOnChart Then Begin .... Same problem. While loading, this condition is true for each bar

I did try with putting my code in a signal instead of an indicator, same problem. All bars are computed

I will look to re-install a condition looking for the machinetime > Initialisation time

Martin

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

Re: If Barstatus = 0 then Begin... Not always detected

Postby arjfca » 09 Mar 2012

Condition to start the code after a given delay as been implemented

Doing so I could say that the condition if T > T[1] is not valid to detect the beginning of a new bar. Because it seem to occur before the start of the new bar. This resulting that the condition is evaluated at the ending of the bar. Value read, are then based on this ending bar


I need to capture, when a bar is starting
- High[1], Low[1], Time[1], Time

With T> T[1] being evaluated at then end of T[1] I got:
as real results: High[2], Low[2], Time[2], Time[1]

So returning to my original question, Is there an alternative to detect and react to the beginning of a bar. If BarStatus = 0 then Begin... Is not always detected

Martin

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: If Barstatus = 0 then Begin... Not always detected

Postby SP » 09 Mar 2012

You could reset the value with each bar instead of t>t[1] with

if currentbar>this.bar then
begin //if new bar
this.bar=currentbar;
...//your values
High[1], Low[1], Time[1], Time;
......
end;
Set the values to intrabarpersist.

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

Resolved: Re: If Barstatus = 0 then Begin... Not always dete

Postby arjfca » 14 Mar 2012

Problem resolved with the help of support@multicharts.com

Need to unchecked the option to skip identical ticks.

Martin


Return to “MultiCharts”