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

Re: [amibroker] Re: Something is different. But what ?



PureBytes Links

Trading Reference Links

To understand "why not" take a look at the array discussion in the Users Guide and think about what the inlongpos array looks like at each bar and what ref(..., -1) is looking at.
 
Bill
----- Original Message -----
Sent: Friday, March 28, 2008 5:52 AM
Subject: Re: [amibroker] Re: Something is different. But what ?

Mike/Bill thanks for the answers. Mike I am already using Flip for LongPos and ShortPos. This works fine for me ( LongPos = Flip(Buy,Sell) and ShortPos=Flip(Short,Cover) ). So that's not my problem. My problem is that I still do not see the difference between the two statements I have given and would like to know why there is a difference. Bill in the first statement your should get same result as with the For Loop. So LongPos will become '1000' as soon as we have a Buy and will switch to '0' again with a 'Sell'. Assume T-1 had a Buy then LongPos(T-1) = 1000. Therefore LongPos(T) will be set to '1000' also. But you're right. This is not what is happening. And I still do not understand why not ...
 
Regards, Ton.
 
----- Original Message -----
From: Mike
Sent: Friday, March 28, 2008 12:33 AM
Subject: [amibroker] Re: Something is different. But what ?

Sorry,

That should probably read Flip(ExRem(Buy, Sell), Sell) * 1000;
And maybe not much easier after all ;)

Mike

--- In amibroker@xxxxxxxxxps.com, "Mike" <sfclimbers@...> wrote:
>
> You could probably leverage the Flip function to make this easier
on
> yourself.
>
> e.g.
>
> Buy = ...
> Sell = ...
> InLongPos = Flip(ExRem(Buy, Sell)) * 1000;
>
> Mike
>
> --- In amibroker@xxxxxxxxxps.com, "wavemechanic" <timesarrow@>
> wrote:
> >
> > The iif() does not give the same result because ref(inlongpos, -
1)
> == 0 except when the previous bar is a buy. You can see exactly
what
> is happening graphically with
> >
> > buy =
> > sell =
> > inlongpos = iif(...
> > plot(c, "", iif(buy, colorred, iif(sell, coloryellow,
> colorpalegreen)), stylebar);
> > title = "inlongpos = " + inlongpos + " ref(inlongpos..." + ref
> (inlongpos...) + " buy = " + buy + " sell =" + sell
> >
> > If you want the iif() approach to hold either a buy or sell value
> for each bar additional code is needed to create this condition.
> >
> > Bill
> >
> >
> > ----- Original Message -----
> > From: Ton Sieverding
> > To: amibroker@xxxxxxxxxps.com
> > Sent: Thursday, March 27, 2008 8:10 AM
> > Subject: Re: [amibroker] Something is different. But what ?
> >
> >
> > Sure. This of course if part of an AFL with Buy and Sell
defined.
> Also an init for InLongPos
> > being set to zero as a starter. Again the ForLoop works fine. I
> checked that with following statement : AddColumn
> (InLongPos,"Long",1);
> > My problem is that I do not understand why the first statement
> does not give me the correct answer where the second does ...
> >
> > Regards, Ton.
> >
> > ----- Original Message -----
> > From: wavemechanic
> > To: amibroker@xxxxxxxxxps.com
> > Sent: Thursday, March 27, 2008 12:55 PM
> > Subject: Re: [amibroker] Something is different. But what ?
> >
> >
> >
> > Is there more to the code? Are you getting a
> syntax/initialization error? How are you handling the case when i
==
> 1?
> >
> > Bill
> >
> > ----- Original Message -----
> > From: "amsiev" <ton.sieverding@>
> > To: <amibroker@xxxxxxxxxps.com>
> > Sent: Thursday, March 27, 2008 7:01 AM
> > Subject: [amibroker] Something is different. But what ?
> >
> >
> > > Why is following AFL statement :
> > >
> > > InLongPos = IIf(Buy==1,1000,IIf(Sell==1,0,Ref(InLongPos,-
1)));
> > >
> > > giving me a different result as following ForLoop :
> > >
> > > for ( i=1; i<BarCount; i++ )
> > > {
> > > if (Buy[i]==1)
> > > InLongPos[i] = 1000;
> > > else
> > > {
> > > if (Sell[i]==1)
> > > InLongPos[i] = 0;
> > > else
> > > InLongPos[i] = InLongPos[i-1];
> > > }
> > > }
> > >
> > > The result I am getting from the ForLoop is correct. The
first
> > > statement gives me a wrong answer. I want to get 1000 in
> InLongPos
> > > after Buy and before Sell ... When testing the statement in
> Excel
> > > it works fine with : =IF(A6=1;1000;IF(B6=1;0;C5)) ...
> > >
> > > What's wrong ?
> > >
> > >
> > > ------------------------------------
> > >
> > > Please note that this group is for discussion between users
> only.
> > >
> > > To get 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
> > >
> > >
> > >
> > >
> > >
> > > --
> > > No virus found in this incoming message.
> > > Checked by AVG.
> > > Version: 7.5.519 / Virus Database: 269.22.0/1344 - Release
> Date: 3/26/2008 8:52 AM
> > >
> > >
> >
> >
> >
> >
> > ----------------------------------------------------------
--
> ----------
> >
> >
> > No virus found in this incoming message.
> > Checked by AVG.
> > Version: 7.5.519 / Virus Database: 269.22.0/1344 - Release
Date:
> 3/26/2008 8:52 AM
> >
>


No virus found in this incoming message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.0/1344 - Release Date: 3/26/2008 8:52 AM
__._,_.___

Please note that this group is for discussion between users only.

To get 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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___