Creating my own synthetic bars, but problem here...

Questions about MultiCharts and user contributed studies.
KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Creating my own synthetic bars, but problem here...

Postby KhaosTrader » 08 Apr 2013

Hi,

I am trying to build daily bars out of 5 min bars.. The code is below, its just a snippet ok, its just a rough bare bones proof of concept thing.. Anyway, when I fire it, it says its trying to reference future data, i need to have a way where this code fires only during the last couple days of the chart... I am thinking thats what i need to do..

Any help or ideas will be appreciated.

Here is code:

Code: Select all

vBarNumber = BarNumber;

if T >= DayEndTime and T[1] < DayEndTime then begin
value1 = findbar(calcdate(date,-2),0);
value2 = findbar(calcdate(date,-1),0);

counter = 1;
for counter = value1 to value2-value1 begin

if Synthetic_DailyBar_Date[vDaysBack] = date[counter] and time[counter]>0 and time[counter]<DayEndTime then begin
Synthetic_DailyBar_High[vDaysBack] = maxlist(Synthetic_DailyBar_High[vDaysBack],high[counter]);
Synthetic_DailyBar_Low[vDaysBack]= minlist(Synthetic_DailyBar_High[vDaysBack],low[counter]);
Synthetic_DailyBar_NbrBarsIterated[vDaysBack] = Synthetic_DailyBar_NbrBarsIterated[vDaysBack]+1;
end;

end;



print
(
"Date: ",NumToStr(Synthetic_DailyBar_Date[vDaysBack],4),
"High = ",NumToStr(Synthetic_DailyBar_High[vDaysBack],4),
"Low = ",NumToStr(Synthetic_DailyBar_Low[vDaysBack],4),
"Iterated = ", NumToStr(Synthetic_DailyBar_NbrBarsIterated[vDaysBack],0)
);
end;

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: Creating my own synthetic bars, but problem here...

Postby KhaosTrader » 08 Apr 2013

Oh,

I set the following values before the main code runs:

Code: Select all

vIterated = 0;
vValHigh = 0;
vValLow = 9999;

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: Creating my own synthetic bars, but problem here...

Postby evdl » 09 Apr 2013

Can you check the chart shift settings in "Format window, tab X-time Scale".

I had the same error messages with my strategy and the problem was that the chart shift was 0%. That is why MC can not look beyond the lastbar on chart. Set it to 30% for example.

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: Creating my own synthetic bars, but problem here...

Postby KhaosTrader » 09 Apr 2013

Thanks for the reply...
I have it set to 20% already, so i dont think that is the problem... it seems that its having a problem looking back in earlier bar formations perhaps? I dont know, its just a guess


Return to “MultiCharts”