Referencing Bar Number and Time of

Questions about MultiCharts and user contributed studies.
kingmins
Posts: 8
Joined: 05 Mar 2013
Has thanked: 1 time

Referencing Bar Number and Time of

Postby kingmins » 05 Mar 2013

Hi, i am new to easylanguage and more used to esignal efs.

I have searched everywhere but i can't seem to find answer of simple question. I am looking to find the bar number and time of certain bars which were calculated.

e.g.

var startingValue(0);

Code: Select all

if high > highest(high,10)[1] then

startingValue = lowest(low,10);
The above is just code example, now all i want is the: bar number of 'startingValue' and time of the bar of 'startingValue'. I want to know the details of the lowest(low,10) bar.

I have tried: time[startingValue] and barnumber[startingValue]+maxBarsBack but this never gives the right values.

How do we extract data from previous bars being calculated???

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Referencing Bar Number and Time of

Postby Henry MultiСharts » 05 Mar 2013

Hello kingmins,

You need to create 2 more variables, for example var0 and var1 in order to save the barnumber or time:

Code: Select all

if low = startingValue then begin 
var0 = barnumber; 
var1 = time; 
end; 

kingmins
Posts: 8
Joined: 05 Mar 2013
Has thanked: 1 time

Re: Referencing Bar Number and Time of

Postby kingmins » 05 Mar 2013

Hi Henry i tried this and again this is giving wrong data.

The way i see it is that the startingValue is calculated e.g. at bar 100. Then if i create
(if low = startingValue then begin) then this will only reference future values instead of looking backwards, i mean the low will only = starting value after starting value has been calculated unless program code re-runs on every single bar at each pass??

Also, do i place this code within the original code??

I tried this and i keep getting wrong values still.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Referencing Bar Number and Time of

Postby Henry MultiСharts » 06 Mar 2013

A variable will keep its value throughout the whole script calculation (if the value was assigned on the bar's close) until you assign a different value to it.
If you need to have all historical values that were assigned to the variable you can create an array. Here is a code our programmer has created for your inquity:

Code: Select all

once cleardebug;

array: startingValue_bn[](0), startingValue_time[](0);
var: count(0), startingValue(0);

once begin
array_setmaxindex(startingValue_bn, Symbol_Length);
array_setmaxindex(startingValue_time, Symbol_Length);
end;

if high > highest(high,10)[1] then
begin
count = count + 1;

var: min_low(0);
min_low = high;
For value1=0 To 10 Begin
if min_low > low[value1] then begin
min_low = low[value1];
startingValue_bn[count] = currentbar - value1;
startingValue_time[count] = time[value1];
end;
End;

print(time:8:0, " ", min_low, " ", startingValue_bn[count]:5:0, " ", startingValue_time[count]:8:0);
end;

Plot1(high);
Plot2(highest(high,10)[1]);

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

Re: Referencing Bar Number and Time of

Postby furytrader » 07 Mar 2013

Unless I misunderstand things, couldn't you use the LowestBar(Low,10) to get this information?

i.e.,

Code: Select all

lowBar = lowestBar(Low,10);
lowTime = Time[lowBar];
lowBarNumber = currentBar - lowBar;
... or something like that?


Return to “MultiCharts”