indicators output updates

Moderator: admin

indicators output updates

Postby pawelas » Thu Sep 30, 2010 10:34 pm

Hi programmers,
I noticed an issue with many indicators, that they update indicators values, but they don't update often indicator output. I wrote before about problems with bigger frame indicators, but also there is issue with current frame indicators.
For example, AO (awesome indicator) histogram doesn't update whole output for current period. I mean, that if you leave chart with AO for some time you will notice that in some cases above red bars sometimes shows yellow, and under yellow bars sometimes you can notice red. Of course if you update/refresh/ charts it disappears.

Can you fix this issue, or give an example how to do updates of output so i can fix it for myself where I need it,

thank you very much
pawelas
 
Posts: 6
Joined: Sun Aug 29, 2010 10:15 pm

Re: indicators output updates

Postby Nikolay.Gekht » Tue Oct 05, 2010 5:37 pm

Let me explain (and if I am not so good in explanation - please do not
hesitate to ask additional questions)

Let's look at AO.lua Update code:
Code: Select all
        if (CL[period] > CL[period - 1]) then
            GO[period] = CL[period];
        elseif (CL[period] < CL[period - 1]) then
            RO[period] = CL[period];
        elseif GO[period - 1] > 0 then
            GO[period] = CL[period];
        else
            RO[period] = CL[period];
        end


This code is supposed fill either GO (green bar) or RO (red bar)
depending on the condition and does so while update is called only
once. However, in case update is called multiple time and condition
changes - it's possible that both GO and RO are be filled.

So, all you need to do is just clear other output when you fill one of
them:
Code: Select all
        if (CL[period] > CL[period - 1]) then
            GO[period] = CL[period];
            RO[period] = nil;
        elseif (CL[period] < CL[period - 1]) then
            RO[period] = CL[period];
            GO[period] = nil;
        elseif GO[period - 1] > 0 then
            GO[period] = CL[period];
            RO[period] = nil;
        else
            RO[period] = CL[period];
            GO[period] = nil;
        end

Yeah, the original implementation is not pretty "fine-polished", but a
bit faster, this is why we don't care about such issues.
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: indicators output updates

Postby pawelas » Wed Oct 06, 2010 11:32 am

nice and easy solution. why i couldn't figure out it by myself :?
Thanks a lot!
pawelas
 
Posts: 6
Joined: Sun Aug 29, 2010 10:15 pm


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 46 guests