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

[amibroker] problem with ATR() and CBT


  • Date: Fri, 12 Feb 2010 13:29:06 -0000
  • From: "tf28373" <tomfid@xxxxx>
  • Subject: [amibroker] problem with ATR() and CBT

PureBytes Links

Trading Reference Links



Hello

As I want to use position sizing based on volatility estimated by ATR() and current equity, I utilize custom backtest procedure. Unfortunately, all my trials to transfer the value of ATR() array into cbt's part of the code fails no matter if using Foreign(...), AddToComposite(...) or StaticVarSet(...) and StaticVarGet(...) afterwards funtions.

These are the most important parts of the code:

//entry signals and setting stoploss level//

for(i=b+1;i<BarCount;i++)//b is a parameter used to compose signal breakout channel

{

Buy[i]=False;

Sell[i]=False;

stop[i]=stop[i-1];

if(long==False AND H[i]>maks[i])//long is a flag indicating opening long position, maks is the upper limit of the channel

{

Buy[i]=True; long=True;

if(C[i-1]<=maks[i] AND O[i]>maks[i])

BuyPrice[i]=O[i]+spread;

else BuyPrice[i]=maks[i]+spread;

stop[i]=maks[i]+spread-e*wtr[i];//wtr is my version of ATR(),  e is a wtr multiplier

AddToComposite(wtr,"wtr","C",64);//or StaticVarSet("stop",stop[i]);

}

Afterwards there are exit and stoploss parts which I will omit and here comes CBT part:

SetCustomBacktestProc("");

if(Status("action")==actionPortfolio)

{

bo=GetBacktesterObject();

bo.PreProcess();

for(i=0;i<BarCount;i++)

{

for(sig=bo.GetFirstSignal(i);sig;sig=bo.GetNextSignal(i))

{

wtr2=Foreign("wtr","C");//or wtr2=StaticVarGet("stop");

position=1000*floor((f/100*bo.Equity)/(e*wtr2)/1000);//f  is a parameter indicating what fraction of equity should be used

 

sig.PosSize=position;

}

bo.ProcessTradeSignals(i);

}

bo.PostProcess();

}

No matter what I choose backtest produce report with no trades  - as the "position"=sig.PosSize is equal to zero...I was trying to nest Foreign(...) ans StaticVarGet(...) functions in different parts of CBT code, however without success.

Please help if you have any hints about the reasons of my problems.

Tomasz

PS I use version 5.20 of Ami



__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___