ADE.TypeZeroBarID_s with Datetime  [SOLVED]

Questions about MultiCharts and user contributed studies.
SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

ADE.TypeZeroBarID_s with Datetime

Postby SP » 24 Sep 2014

I used for tick / volume charts

Code: Select all


save_global_data( SymbolName, ADE.TypeZeroInterval(TypeCode, IntervalSize), ADE.TypeZeroBarID_s,"_MyMovAvg", MyMovAvg);
to send some values from the scanner to the charts, but now i want to use datetime in the
ADE.TypeZeroBarID_s function as i have some problems since the miliseconds are introduced in MC 8.

Do i only need to change time_s with datetime at the following code?

Code: Select all

[LegacyColorValue = TRUE];

Vars:
BarInfo(ListN.New);

if CurrentBar = 1 and ListN.Count(BarInfo) = 0 then begin
Value1 = ListN.PushBack(BarInfo, CurrentBar);
Value1 = ListN.PushBack(BarInfo, Time_s);
Value1 = ListN.PushBack(BarInfo, 1); // bar counter
end;

if CurrentBar <> ListN.Get(BarInfo, 1) then begin // are we on a new bar?
if Time_s <> ListN.Get(BarInfo, 2) then // has bar time changed?
Value1 = ListN.Put(BarInfo, 3, 1) // reset counter to 1
else
Value1 = ListN.Put(BarInfo, 3, ListN.Get(BarInfo, 3) + 1); // increment counter

// Store new bar number and time
Value1 = ListN.Put(BarInfo, 1, CurrentBar);
Value1 = ListN.Put(BarInfo, 2, Time_s);
end;

// before here was "Time" - HHMM - delimeter = 10000, now "Time_s" - HHMMss - delimeter = 1000000 {ADDED ADDITIONAL "0"}{MIKE ADDED 000}
ADE.TypeZeroBarID_s = Date + ListN.Get(BarInfo, 2) / 1000000000+ ListN.Get(BarInfo, 3) / 1000000000;



User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: ADE.TypeZeroBarID_s with Datetime  [SOLVED]

Postby Andrew MultiCharts » 24 Sep 2014

Hello SP,

If you use (datetime2eltime_s(ListN.Get(BarInfo, 2))*1000+MillisecondsFromDateTime(ListN.Get(BarInfo, 2)))/1000000000, it should work fine.

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

Re: ADE.TypeZeroBarID_s with Datetime

Postby SP » 24 Sep 2014

Thanks Andrew,

seems to work without problems now. I posted a new thread in the "User Contributed Studies and Indicator Library" so that others may also benefit from.

viewtopic.php?f=5&t=47238


Return to “MultiCharts”