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

Declare variable for future use (was TJ: Actual trade profit vs. Theoretical)



PureBytes Links

Trading Reference Links

Hi, all!

Well, so far no any response on my initial post (even on direct e-
mail to support@xxxx). It's weird. Maybe my question wasn't 
clear, or Tomasz was too busy.

OK, let me ask in a different way. Is there any way in AFL to declare 
variable/array and use its previos value before setting current one?

I mean:

// var tradeProfit; // declare variable for future use

Buy = longEntry and ValueWhen(Sell, tradeProfit) < 0;
Sell = LongExit;

tradeProfit = ValueWhen(Sell, SellPrice) - ValueWhen(Buy, BuyPrice);


Any suggestions are welcome.

Thanks,
Mike


--- In amibroker@xxxx, "mik954" <mik-u@xxxx> wrote:
> Tomasz,
> 
> On February 22, 2002 you wrote the code for teoretical trade profit:
> 
> <<<cut here>>>
> 
> Let's suppose that you system generates
> entry and exit signals based on break out:
> 
> LongEntry = ... formula here ...
> LongExit = .... formula here...
> 
> Now you can
> 
> LongEntry = ExRem( LongEntry, LongExit );
> LongExit = ExRem( LongExit, LongEntry );
> 
> TheoreticalTradeProfit = ValueWhen( LongExit, SellPrice ) -
> alueWhen( LongEntry, BuyPrice );
> 
> Buy = LongEntry AND TheoreticalTradeProfit < 0; // enter only if 
> previous trade was loosing
> Sell = LongExit;
> 
> <<<cut here>>>
> 
> Could you tell me please how in AFL I may calculate trade profit 
> based on ACTUAL Buy/Sell signals to use previos profit value in 
next 
> Buy signal calculation?
> 
> I mean a code like this:
> 
> <<<cut here>>>
> 
> var tradeProfit; // declare variable for future use
> 
> Buy = longEntry and Ref(tradeProfit, -1) < 0;
> Sell = LongExit;
> 
> tradeProfit = ValueWhen( Sell, SellPrice ) - ValueWhen( Buy, 
> BuyPrice );
> 
> <<<cut here>>>
> 
> 
> Thanks,
> Mike