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

[amibroker] Re: Alter PointValue() in AFL - not working



PureBytes Links

Trading Reference Links

Hello,

Shortly speaking: PointValue variable that you are plotting is not affected by custom backtester code. In fact custom backtester code is not even executing in context of indicator. Your formula has if statement that enters only when run in AA / Backtest and not anywhere else.
If you are using if statements it is useful to have _TRACE commands that will tell you whenever given part is executed or not.
Even if this part did execute you would not see any change in PointValue variable because signals keep a copy of PointValue values not the reference.
Having said that I am not sure why won't you to change point value on trade-by-trade basis. PointValue is property of the symbol and does not change on bar-by-bar basis. Anyway the backtest results react appropriately to change of point value (despite that you can not "plot" it). Not that point value  is only available for entry signals. Trade then uses point value of entry point for all trade calculations including the exit.  

Best regards,
Tomasz Janeczko
amibroker.com

--- In amibroker@xxxxxxxxxxxxxxx, "dralexchambers" <dralexchambers@xxx> wrote:
>
> Hi,
> 
> I'm using the Custom Backtester Code to alter PointValue for each 
> trade. I intend to alter the PointValue for each trade according to 
> Equity and a few other calculations.
> 
> I tried the code below and it isn't working. I'm setting PointValue 
> to an arbitary number (300) just to test the code, and plotting the 
> PointValue to see the output.
> 
> Can anyone suggest - thanks.
> 
> 
> SetCustomBacktestProc(""); 
> 
> if( Status("action") == actionPortfolio )
> {
>   bo = GetBacktesterObject();
>   bo.PreProcess();
>   for( bar = 0; bar < BarCount; bar++ )
>   {
>    CurrentPortfolioEquity = bo.Equity;
>    for( sig = bo.GetFirstSignal( bar ); sig; sig = bo.GetNextSignal( 
> bar ) )
>     {
>     sig.PointValue = 300;
>     }
>    bo.ProcessTradeSignals( bar );
>   }
>   bo.PostProcess();
> }
> 
> Plot(PointValue,"PV",colorGreen,styleDots|styleOwnScale);
>



Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.37/682 - Release Date: 2/12/2007 1:23 PM