PureBytes Links
Trading Reference Links
|
Hello Bernard,
Cum() function calculates cumulative sum for all bars since
bar 1.
If you write something like that:
CumProfit = Cum( IIF( IsEmpty( Profit ),
0, Profit )
and there are 5 days between one trade and the second trade
your
single trade Profit will be added (cummulated) for those 5
bars and this is wrong.
The purpose of my code:
CumProfit = Cum( IIF( IsEmpty( Profit * sell ), 0, Profit *
sell ) );
was to cumulate Profit only on bars when actual "sell"
condition occured, i.e.
when the trade was closed. This is the reason why I used
Profit * sell
expression - it gives you Profit value on the day when sell
occurred and zero
otherwise. If you then perform cumulative sum - you will get
your desired
cumulative profit.
Best regards,Tomasz
Janeczko------------------------------------------------AmiBroker -the
comprehensive share manager<A
href="">http://www.amibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Bernard
Bourée
To: <A title=amibroker@xxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Tuesday, August 14, 2001 6:29
PM
Subject: Re: [amibroker]
Exploration
Hi Franck and Tomasz,
Thank you very much for your help.
Franck you are right my intention was towrite
PProfit, but it also does not work.
Tomasz with your modification I have some results
but not what I'm waiting for.
I'm looking to have in the last column the profit
accumulated trade by trade.
so I have modified the code with:
CumProfit = Cum( IIF( IsEmpty( Profit ), 0,
Profit ) );
But as you can see in the attached jpg, the
calculated values are not correct.
What am I missing ?
Thank you very much for your help.
Bernard Bourée<A
href="">bernard@xxxx
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Tomasz Janeczko
To: <A title=amibroker@xxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, August 12, 2001 11:05
PM
Subject: Re: [amibroker]
Exploration
Hi Bernard,
There are some small mistakes in your
formula,
here comes fixed one:
buy = cross (macd(), 0);sell = cross (
0, macd()); buy = exrem( buy, sell);sell = exrem (sell,
buy); position = iif(buy, 1, iif( sell, -1, 0));buyprice =
ValueWhen( buy, C, 1);sellprice = ValueWhen( sell, C, 1);profit =
buyprice - sellprice; PProfit = 100 * Profit /
BuyPrice;
CumProfit = Cum( IIF( IsEmpty( Profit *
sell ), 0, Profit * sell ) );
filter =sell; numcolumns =
6;column0 = position;column0Name ="Pos.";column1=
buyprice;column1Name = "Buy p.";column2 = sellprice;column2Name
= "Sell P.";column3 = profit;column3Name = "Profit";column4 =
PProfit;column4Name = "Profit%";column5 = CumProfit;column5Name
= "CumProf.";
Best regards,Tomasz
Janeczko------------------------------------------------AmiBroker -
the comprehensive share manager<A
href="">http://www.amibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Bernard
Bourée
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, August 12, 2001 9:18
AM
Subject: [amibroker]
Exploration
Hello
I have the following exploration
:
buy = cross (macd(), 0);sell = cross ( 0,
macd());
buy = exrem( buy, sell);sell = exrem
(sell, buy);
position = iif(buy, 1, iif( sell, -1,
0));buyprice = valuewhen( buy, C, 1);sellprice = ValueWhen( sell,
C, 1);profit = buyprice - sellprice;
PProfit = 100 * Profit /
BuyPrice;CumProfit = Sum( Profit, BarsSince(Profit));
filter =buy or sell;
numcolumns = 6;column0 = position;column0Name
="Pos.";column1= buyprice;column1Name = "Buy p.";column2 =
sellprice;column2Name = "Sell P.";column3 = profit;column3Name
= "Profit";column4 = PProfit;column4Name = "Profit%";column5 =
CumProfit;column5Name = "CumProf.";
Everything is OK except for the CumProfit which give 0.
The idea is to obtain in this column the cumulative profit tradeby
trade.
Any idea ?
Bernard Bourée<A
href="">bernard@xxxxYour
use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
|