PureBytes Links
Trading Reference Links
|
Thanks Turzo for those explanations.
Wouldn't it be possible to simply write
if( Buy[ i ] ) { priceatbuy = BuyPrice[ i ];
}
instead of
if( priceatbuy == 0 AND Buy[ i ] ) { priceatbuy = BuyPrice[ i ]; }
if the priceatbuy value was already set to zero before the "for" command? I mean: we already know that the only possible value of priceatbuy at this point was zero, so why add the if (priceatbuy == 0... ? and not simply if (Buy [i]...
I think I am very close to understand this, but I am still missing a point. I don't understand why there are multiple values set to zero before the loop, and why suddenly priceatbuy would be greater than zero when I am in a trade. I mean: it is clear to me that priceatbuy is the price at which there was a trade involved and that anything bigger is necessarily greater than 0 if priceatbuy is zero. However (and that is my point) I don't see anything yet in the formula defining "priceatbuy" as the entry point. So far in the formula "priceatbuy" is only 0 and nothing else than that. I don't understand why that value would be greater or equal to zero. Maybe it is related to the
for( i = 0; i < BarCount; i++ ) {
and I don't understand completely that part?
Thanks for helping. I appreciate a lot. I am still a newbie but I feel confident I will catch up and be able to help others as well.
Louis
2008/2/23, tuzo_wilson <j.tuzo.wilson@xxxxxxxxx>:
--- In amibroker@xxxxxxxxxxxxxxx, "Louis Pr�fontaine" <rockprog80@xxx>
wrote:
> I now understand that for each bar "i", the program now looks if the bar
> value is less than the barcount and then apply the formula below.
But what
> I don't understand there is how can "priceatbuy" differ from 0 since
it was
> defined as 0 just over (first line of the code). How could
"priceatbuy",
> which was given a value of 0 could have a value over 0 then?
>
> I understand that the bar in which a buy was issued is represented
as Buy
> [i], but why the "priceatbuy ==0" before?
priceatbuy is set to 0 before the loop but the the value is also set
within the loop. If priceatbuy is 0 and Buy[i] is non-zero then
priceatbuy is set to the BuyPrice[i]. i.e. if there is a buy signal
and we haven't set the buyatprice then set the buyatprice to be the
Buy Price for that bar.
Basically, priceatbuy lets you know if you are in a trade. If it's
zero then you aren't in a trade but if it's non-zero then you are in a
trade so you need to check the profit target exit criteria.
> priceatbuy=0;
> highsincebuy = 0;
> exit = 0;
> for( i = 0; i < BarCount; i++ )
> {
> if( priceatbuy == 0 AND Buy[ i ] )
> {
> priceatbuy = BuyPrice[ i ];
> }
> if( priceatbuy > 0 )
> {
> highsincebuy = Max( High[ i ], highsincebuy );
> if( exit == 0 AND
> High[ i ] >= ( 1 + FirstProfitTarget * 0.01 ) *
> priceatbuy)
Tuzo
__._,_.___
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
__,_._,___
|