hi
I want to test a system by finding total profits generated.I am able to get
tradewise profits but not able to get scripwise profit and total profit
generated.Follo is my code
Buy = Cross(*C* , MA(*C*,10));
*
Sell* = Cross(MA(*C*,10),*C*);
buyat = ValueWhen(*Buy*,*C*,1);
sellat = ValueWhen(*Sell*,*C*,1);
profit = Sellat-buyat;
profitpercent = profit/buyat * 100;
to get total profits i have tried following one at a time
totProfit = Sum(profitpercent,*BarCount*);
or
totprofit = cum(profitpercent);
or
totprofit = 0;
for (i=0;i++;i<barcount-1)
{
totprofit[i] = totprofit[i-1]+profitpercent[i];
}
Filter = *Buy* *OR* *Sell*;
AddColumn(*Buy*, "Buy", 1.2);
AddColumn(*Close*, "Close", 1.2);
AddColumn(IIf(*Buy*,Buyat,0), "BuyPrice", 1.2);
AddColumn(IIf(*Sell*,Sellat,0), "SellPrice", 1.2);
AddColumn(IIf(*Sell*,Profit,0), "Profit", 1.2);
AddColumn(IIf(*Sell*,ProfitPercent,0), "Profit%", 1.2);
AddColumn(IIf(*Sell*,TotProfit,0), "TotProfit%", 1.2);
after i run above I get zero in last column except in cum() function where i
get some numbers which are not correct.
I would be grateful if someone could help
TIA