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

[amibroker] Re: Average: barssince, cum(1), sum ??



PureBytes Links

Trading Reference Links

Hi Corey,

The formula works, but not to the value I'm trying to average. Maybe 
I didn't explain my self correctly.

If I looking back on a time period of 250 days. I want to know how 
many actual bars were above .15, ie. was it 30 or 60 or etc..., that 
were above the 250 day period.

I then want to take value of the # of bars up (lets say is was 30 
bars)and divide this by the # of bars (30).

My son has been trying to help me out with this, and the following is 
what he got so far, but be aware, this script does not run because it 
has syntax errors. Damn those syntax's!

PPO = (EMA(C,20)-EMA(C,50)) / EMA(C,50);
y = 0 ;
x = 0;
ppav = 0;
ppa = 0;


while (y != 250 ) // keep going until you have 250 bars
{
  if (Ref(ppo,-y) > 0) {  // checks that the bar -y(past bar) is 
above 0
    x++; 
    y++; //adds 1 to the number of bars to go back
}
}

t = x;

while (x != 0) {  // keep going through all the bars
ppa = ppa + Ref(ppo,-x); //adds all the past ppo's above 0 together 
x = x - 1;  // counts down untill there are no bars left
}


Donna


--- In amibroker@xxxxxxxxxxxxxxx, "CS" <res1wgwl@xxxx> wrote:
> 
> PPO = (EMA(C,20)-EMA(C,50)) / EMA(C,50);
> A1=Sum(PPO>0.015,250)/250;
> 
> // OR
> A2=MA(PPO>0.015,250);
> 
> Plot(A1,"Sum method",2,1);
> // OR
> Plot(A2,"MA method",1,1);
> 
> It will take at least 250+ bars to show a result.
> 
> -Corey Saxe
> 
> 
> ----- Original Message ----- 
> 
>   From: donna girardin 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Saturday, December 06, 2003 2:53 AM
>   Subject: [amibroker] Average: barssince, cum(1), sum ??
> 
> 
>   Hi everyone,
> 
>    
> 
>   I'm new to AB and am having trouble determining the code concepts 
of the AFL language.  What I'm trying to code is a simple math 
function, but no matter how many different variables I use, I can't 
get it J. I have tried using functions of barssince, cum(1), sum, = 
=, y !=, ++y, but I can't put any of it together to obtain my value.
> 
>    
> 
>   I'm trying to obtain the average value for my code:
> 
>    
> 
>   PPO = (EMA(C,20)-EMA(C,50)) / EMA(C,50);
> 
>    
> 
>   What I want to do is; 
> 
>    
> 
>   sum value, over my time frame -- x =250 days,  that PPO was 
above .15 then divide the sum value by the total # of count days 
(bars),over my time frame -- x =250 days, that PPO was above .15. 
Hence my average.
> 
>    
> 
>   Is there anyone that can help me?
> 
>    
> 
>   Donna
> 
> 
> 
> 
> 
> --------------------------------------------------------------------
----------
>   Post your free ad now! Yahoo! Canada Personals
> 
>         Yahoo! Groups Sponsor 
>               ADVERTISEMENT
>              
>        
>        
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
>   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>   --------------------------------------------
>   Check group FAQ at: 
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/