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

Questions about MultiCharts and user contributed studies.
sptrader
Posts: 622
Joined: 09 Apr 2010
Location: Colorado
Has thanked: 388 times
Been thanked: 229 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: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

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

Postby TJ » 12 Jan 2012

sptrader wrote: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
function.gif (7.85 KiB) Viewed 111 times

sptrader
Posts: 622
Joined: 09 Apr 2010
Location: Colorado
Has thanked: 388 times
Been thanked: 229 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”