[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NumericArrayRef and NumericArray ? ( Thank U Howard ! !)



PureBytes Links

Trading Reference Links

Sorry for not replying earlier. I was away for most of
the week (seemed like a good time to sneak in a quick
vacation).

An example? ok:

Suppose you trade options, and you want to calculate
the theoretical value, delta, gamma, theta, vega, etc.
Most of the calculations for these values are
redundant. Instead of having one function per number
(one function for t.v., one for delta, one for gamma,
etc) that duplicate all the calculations you have one
function that crunches all the numbers once and
returns ALL the values at the same time. You would use
it like this:

Indicator:
----------
Variable: tv(0), delta(0), gamma(0), vega(0);

value1 = MyPricingModel( tv, delta, gamma, vega);

Plot1( tv, "TV");
Plot2( delta, "d");
Plot3( gamma, "g");
{ ... etc, etc... }

Function MyPricingModel()
-------------------------

Input: tVal(numericRef), MyDelta(numericRef),
MyGamma(numericRef), MyVega(NumericRef);

{here would go all the caclulations}
tVal=value1;
MyDelta=value2;
MyGamma=value3;
MyVega=value4;

MyPricingModel = 1;
{end of function}

A different example would be calculating bollinger
bands. If you think about it, each time you calculate
bollinger bands (which are X standard deviations above
and below the market) by using the current EZL
function you are calculating the average and then the
standard deviation. So if you call the bollinger band
function twice (one for the upper and one for the
lower band) then you are doubeling up all your
calculations. With the reference stuff, you can have
one function that does the calculation ONCE and
returns BOTH values.

Now with arrays, if your indicator or system is
keeping track of information through an array and you
need to sort the array, you can send the array to a
function and have the function sort it. That way you
save yourself the hassle of writting the sort in your
system or indicator every time you need it. THis is
the example that the guy in support forwarded you.

This was one of the main reasons why I did not develop
more stuff in EasyLanguage before (because TS4 does
NOT have this). Hope this helps.

And this post demonstrates why some programming
background in other languages can be very useful in
this business at this particular time in the computer
revolution age... 

:-)

Hope this helps.

H

--- Jwtrader@xxxxxxx wrote:
> Howard,
>    Thank you very much for your generous
> contribution to this list.  Somehow 
> I feel that you have just said something that's
> highly intelligent and 
> useful--- now if only I could figure out what you
> just said, I would be 
> forever grateful.  Would you care to give an example
> of using NumericRef and 
> NumericArrayRef ?
>    I would also like to thanks Bob Fulks ( and many
> others) for his generous 
> contribution to this list.
> 
> Regards,
>   Jim
> 
>   " Dare to be different- it could save your life
> "...... 
> 
>   ........
> >The exact same applied to passing arrays and
> variables
> >when programming. What EasyLanguage allowed you to
> do
> >in ts4 was pass by value, so your functions were
> >creating (local) copies of the variables you had in
> >your main program (be it an indicator or a system).
> >Now you can have functions receive parameters by
> >reference, so functions can alter the values of
> arrays
> >and variables of the main program.
> >This will allow functions to return more than one
> >value! neat stuff...
> 
>