Function for "Entry Bar Close" - works in TS but NOT in MC

Questions about MultiCharts and user contributed studies.
sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Function for "Entry Bar Close" - works in TS but NOT in MC

Postby sptrader » 12 Jan 2012

I wrote this function back in 99' for use in TS and it always worked great but when I try it in MC, it either gives a "bars back error" or returns the wrong value when applied to a Signal..
It's so simple, I can't see what causes the problem with it in MC..
Instead of calling the function, I even put the code directly into the signal and it still didn't work.

Code: Select all


vars:Ebar(-9999); {entry bar}

if barssinceentry(0) = 0 then begin
Ebar = currentbar;
end;
EntryBarClose = C[currentbar-Ebar];

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

Re: Function for "Entry Bar Close" - works in TS but NOT in

Postby TJ » 12 Jan 2012

I wrote this function back in 99' for use in TS and it always worked great but when I try it in MC, it either gives a "bars back error" or returns the wrong value when applied to a Signal..
It's so simple, I can't see what causes the problem with it in MC..
Instead of calling the function, I even put the code directly into the signal and it still didn't work.

Code: Select all


vars:Ebar(-9999); {entry bar}

if barssinceentry(0) = 0 then begin
Ebar = currentbar;
end;
EntryBarClose = C[currentbar-Ebar];
I have just compiled the function and applied it to an indicator on a 1 min ES chart with no problem.

Please make sure you create the function as Numeric and Series.

Image
Attachments
function.gif
(7.85 KiB) Downloaded 225 times

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Function for "Entry Bar Close" - works in TS but NOT in

Postby sptrader » 12 Jan 2012

Thanks TJ, you've done it again !!!
*******************************
I think an easier way could be (don't know why I didn't think of that first)

Code: Select all


C[barssinceentry];


Return to “MultiCharts”