PureBytes Links
Trading Reference Links
|
TS and AB have no concept of constants only variables. What appears to
be constants in the TS code are pre-declared variables, they can be
changed. The same in AB.
The TS inputs: declaration are the passed arguments to the function.
Don't need var 'n' or the 'length' test, as AB guarantees enough bars
before the code is run.
function TSMStDevConfidence(pArray, len)
{
local sd, diff, diff2, const;
diff = pArray - Sum(pArray, len)/len;
diff2 = diff^2;
sd = sqrt(Sum(diff2, len)/len);
// AB provides an exponential function named exp(), so need a var
name change
rexp = sd * sd / 2 * -1; // also change the sign here
// only using pi once, so don't need to declare a var for it
const = 1 / sqrt(3.1415926 * 2); // = 0.39894228 could use this
result directly below
// can't return the result from a calculation directly? yet. so assign
rv = 100 - 100 * const * (2.7182818^rexp);
return rv;
} // fi TSMStDevConfidence(..)
// call the function & display ...
Plot(TSMStDevConfidence(Close, 25),"",colorCustom12,styleLine);
Hope this helps.
Mac
--- In amibroker@xxxxxxxxxxxxxxx, "greg_bender2002"
<greg_bender2002@xxx> wrote:
>
> I am trying to convert TradeStation code to AFl. I am a beginner in
> essay language. If someone familiar with trade station code can
> explain how the code below works I think I can figure out how to do
> the conversion. The code below is a function called by another
> indicator. I am confused by what appears to be variables and
> constants and how they are handled. Any explanation would be hugely
> helpful and appreciated.
>
> [LegacyColorValue = true];
>
> { TSMStDevConfidence : Standard deviation confidence level (in
> percent)
>
>
> Returns confidence level, e.g., if stdev = 2.0 then confidence =
> 95.44,
> including both ends of the curve. To find confidence of one end of
> the
> distribution, divide result by 2. }
>
> inputs: price(numericseries), length(numericsimple);
> vars: n(0), pi(3.1415926), e(2.7182818), exp(0), sd(0), diff
> (0), diff2(0),
> const(0);
>
> n = length;
> if currentbar < length then n = currentbar;
> diff = price - average(price,n);
> diff2 = power(diff,2);
> sd = squareroot(average(diff2,n));
>
> exp = sd*sd / 2;
> const = 1.00 / squareroot(2*pi);
> TSMStDevConfidence =100 - 100 * const * power(e,-exp);
>
------------------------------------
**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
*********************************
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|