Hello everyone


I decided to restart this topic, as I try to build a formula dedicated
to perform multi-system/timeframe/symbol backtest and face some problems
with this task.



Just for a introducion: a generic formula is supposed to include some
basic settings (using a couple of "SetOption" functions), afterwards
rows with a simple "if(Name()="xxxx")", each of them calling a special
function (or a few - depending on the number of systems utilized for
some symbol). The functions are suppossed to enable the user - through
the input parameters - to specify a timeframe and system idntification
no. (among other "trading" parameters).



The problem raises when it comes to perform backtest itself and
backtester "yell" for Buy/Sell/Short/Cover variables assigment.  The
point is that they are included in the special funtions.



So my first question is:

Can I omit somehow this "restriction" (puting Buy/Sell/etc variables
directly in basic formula) guiding backtester to use Buy/Sell/etc put in
the special function?

In case you advice me to ex. implement some "switch" statement with
expression that calls special function and obtains funtion's returned
value, use this value in "case" statements to in order to assign it to
either "Buy" or "Sell" etc variables (and then set some
"Buy-/Sellprice/etc) I want to indicate that I've tried this solution,
without success though.



All ideas warmly welcomed! :)



Below the example codes (shortened and simplified) of the formula and
the special function:



main formula:

------------------------------------------------------

a=10000;

SetOption("InitialEquity",a);

//...a couple od other SetOption() statements

PositionSize=1000;

#include <sys1.afl>

#include <sys2.afl>



if(Name()=="xxxx")

{


sys1(0.025,0.001,100,15,360,185,6.25);//parameters: spread on
symbol,ticksize,system id,timeframe,entry param, exit param,stoploss
param


sys2(....)

}

if(Name()=="xxxx")

{

//analogically to first symbol

}

if(Name()=="xxxx")

{

//as above

}

------------------------------------------------------------------------\
--------------

Special function:

------------------------------------------------------------------------\
---------------

function  sys1(spred,tik,system,skala,ent,exit,stoplos)//spred - spread
for symbol,tik - ticksize, system - system id, skala - timeframe,
ent/exit/stoplos - //"trading" params

{

spread=spred;

TickSize=tik;

/*switch (skala)//this part is still under construction, so please skip
it while analysing

{

case 60: TimeFrameSet(inHourly); break;

case 15: TimeFrameSet(in15Minute); break;

case 5: TimeFrameSet(in5Minute); break;

default: break;

}*/



b=ent;

d=exit;

hill=IIf(BarIndex()<=b+1,Null,Ref(HHV(H,b),-1));

depression=IIf(BarIndex()<=d+1,Null,Ref(LLV(L,d),-1));

//ATR//my own ATR, works fine - please skip it

k=20;

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

{

m[i]=Max(abs(C[i-2]-H[i-1]),abs(C[i-2]-L[i-1]));

tr[i]=Max(H[i-1]-L[i-1],m[i]);

}

watr_p[0]=0;

for(i=2;i<k+2;i++)

{

watr_p[i]=tr[i]+watr_p[i-1];

}

watr[0]=0;

watr[k+1]=watr_p[k+1]/k;

for(i=k+2;i<BarCount;i++)

{

watr[i]=((k-1)*watr[i-1]+tr[i])/k;

}

StaticVarSet("watr_"+Name()+"_"+skala+"_"+system,watr);

//TimeFrameRestore();

//stop//

e=stoplos;

//entry, exit and stoploss//as you will notice I use loops to obtain
signals - this is due to some backtesting issues which I'll omit here,
THIS FORMULA WORKS WELL (AT LEAST WHEN SYSTEMS ARE DEVELOPED AND
OPTIMIZED SEPERATLY)

long=False;

stop=C;

kurs=C;

for(i=0;i<b+1;i++)

{

Buy[i]=False;

Sell[i]=False;

}

for(i=b+1;i<BarCount;i++)

{



Buy[i]=False;



Sell[i]=False;

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



if(long==False AND H[i]>hill[i])

{



Buy[i]=True; long=True;



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

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

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

stop[i]=BuyPrice[i]-e*watr[i];

kurs[i]=BuyPrice[i];

}

if(long==True AND L[i]<depression[i])

{



Sell[i]=True;  long=False;



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

SellPrice[i]=O[i]-spread;

else SellPrice[i]=dol[i]-spread;

kurs[i]=SellPrice[i];

}

else if(dluga==True AND L[i]<stop[i])

{



Sell[i]=True;  long=False;



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

SellPrice[i]=O[i]-spread;

else SellPrice[i]=stop[i]-spread;

kurs[i]=SellPrice[i];

}

}

return;

}

------------------------------------------------------------------------\
------------------------------------

Sorry for the layout - I always have problems with puting all stuff in
proper manner using rich text editor.



--- In [email protected], "bh.hicks" <bh.hi...@...> wrote:
>
> I am basically looking for a way to have AmiBroker run multiple
systems concurrently in order to examine how trading multiple
non-correlated strategies affect drawdowns. I think if there was a way
to "name" an entry condition so that stops and position sizing rules
could be applied to a particular entry criteria, it would be possible to
do without too many changes to AB architecture.
>
> I can already do this in excel using exported equity curves but it
would be nice to be able to do this internally so that the optimizer
engine could be exploited.
>
> Is anyone aware of a technique to do this and if not, is this
something others would find useful if integrated into a future version?
>
> As always - thank you.
>


Reply via email to