Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
i am trying to code a variable HaOpen (my modified open for Heikin Ashi) which depends on HaClose (modified close).
HaOpen is basically ((HaOpen[previous]) + smooth * ( HaClose – HaOpen[previous])), but the first value when the calculation starts HaOpen[previous] will be undefined or null, therefore to avoid that situation i want to define first value of HaOpen[previous] as HaClose and afterwards it will take HaOpen[previous] value by itself.
now, i tried coding it on multicharts, where the code is running flawlessly:
value1= IFF (vOpen[1] > 0, vOpen[1], vClose);
vOpen= ((value1) + smooth * ( vClose - value1));
in Amibroker i tried this:
if
(typeof (HaOpen) == "undefined")
{
HaOpen = HaClose;
}
HaOpen = Ref(HaOpen, -1) + smooth * (HaClose - Ref(HaOpen, -1));
which is giving different values of HaOpen in Ami and Multicharts on same data even when values of HaClose are the same.
but all efforts are going in vain as it is asking to initialize HaOpen first, when I am initializing it to anything, it is not updating the new value of HaOpen and instead taking the value initialized throughout the chart.
I made an excel worksheet applying the excel formulae to get what i want and the results are matching completely with multicharts, but not with amibrokers leading to a lot of frustration. :|
Somebody please help. If you don't understand this please ask me. Thanks in anticipation!!
P.S: I am a newbie in afl coding and trying my best.
Can you help answer these questions from other members on NexusFi?
when referring to the previous value of HaOpen it is taking the value of whatever i am initializing it to.
say, if i initialize it as HaOpen = HaClose; then in the next line of HaOpen =Nz(Ref (HaOpen, -1) )+ smooth * (HaClose - Nz(Ref(HaOpen, -1))); it takes the value of HaClose everytime HaOpen is referred to and likewise with zero.