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

[amibroker] Progress of my Exploration and a little more help please !



PureBytes Links

Trading Reference Links

Yuki,
It seems you need the nearest power of 10, ie a result 6643 should be 
rounded to 6000 or a 345 should be rounded to 300.
There are some ways to do that.
a.

PrimeA=1;
m=1000000*(10+3*PrimeA);
shares=LastValue(m/C);
n=1;
for(n=1;n<10;n++)
{
rnd=floor(shares/10^n);
if(rnd>=1)
{
Rshares=rnd*10^n;
}
}
Filter=1;
AddColumn(shares,"Shares",1.0);
AddColumn(Rshares,"Rshares",1.0);

b.
Read the first digit of m/C and fill the rest with zeros.

PrimeA=1;
m=1000000*(10+3*PrimeA);
shares=LastValue(m/C);
im=NumToStr(shares,1.0);
ex=-1+StrLen(im);
sig=StrLeft(im,1);
Rshares=StrToNum(sig)*10^(ex);
Filter=1;
AddColumn(shares,"Shares",1.0);
AddColumn(Rshares,"Rshares",1.0);

c.
The logarithmic way will give you the significant [first] digit of 
shares and fill the rest with zeros.
PrimeA=1;
m=1000000*(10+3*PrimeA);
shares=LastValue(m/C);
d=int(log10(shares));
sig=int(shares/10^d);
Rshares=sig*10^d;
Filter=1;
AddColumn(shares,"Shares",1.0);
//AddColumn(sig,"sig",1.0);
//AddColumn(d,"",1.0);
AddColumn(Rshares,"Rshares",1.0);

d.
Read the first digit and change the rest to "0".
PrimeA=1;
m=1000000*(10+3*PrimeA);
shares=LastValue(m/C);
im=NumToStr(shares,1.0);
imm=StrLeft(im,1);
for(j=1;j<StrLen(im);j++)
{
imm=imm+"0";
}
Rshares=StrToNum(imm);
Filter=1;
AddColumn(shares,"Shares",1.0);
AddColumn(Rshares,"Rshares",1.0);

Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, Yuki Taga <yukitaga@xxxx> wrote:
> Hi Gordon,
> 
> Sunday, July 4, 2004, 2:53:18 PM, you wrote:
> 
> G> This looks like a simple syntax issue:
> 
> G> IIf(PrimeA, AddColumn(13000000 / Close, "Shares", format = 1.0),
> G> AddColumn(10000000 / Close, "Shares", format = 1.0));
> 
> G> would be
> 
> G> AddColumn(
> G>     IIf(PrimeA, 13000000 / Close, 10000000 / Close),
> G>     "Shares", 1.0
> G>     );
> 
> G> You don't need the "format = ", btw. Hope it helps.
> 
> It appears you are absolutely correct.  Now, setting PrimeA = true 
or
> false varies the "Shares" amount.
> 
> Why?  I don't understand.  Why can I not format this?
> 
> I ask because I want to even add more complexity to this statement.
> For example, I trade some stocks that are very expensive (more than
> US$10,000 per share).  These stocks have a trading unit of 1 share.
> In these cases I don't need a format statement.  It is what it is in
> those cases.
> 
> But, other stocks I trade have a trading unit of 1,000 shares, and
> some stocks I trade have a trading unit of 100 shares. So, I'd like 
a
> format statement to round down to the nearest 1,000, or nearest 100,
> based on the symbol.
> 
> How can I do this if a format statement breaks my code?
> 
> Many thanks by the way.  I would never have guessed at the solution.
> 
> Yuki



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> 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/