RE: [amibroker] Re: Backtest multiple systems across multiple timeframes

2010-09-09 Thread Matthias K.
Thanks Tomasz,

It s gonna take me some time to understand your idea. I'm  not very
satisfied with the overall way AB is handling this kind of topic.. anyways
thanks for the assistance. could you explain a little more on how you put
the #include statements? 

 

How many systems did you plug together? How many different timeframes? Did
optimization for capital allocation work? (optimize percentrisked)

 

Greets,

 

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of tf28373
Sent: Donnerstag, 9. September 2010 11:01
To: amibroker@yahoogroups.com
Subject: [amibroker] Re: Backtest multiple systems across multiple
timeframes

 

  

Hi Matthias

Some time ago I was working on the same problem. The solution I have come
across is as following:

1) use #include command in the main code
2) inside the #include function do like this (of course all is just an
example which will need adjustment to your needs):
a) function(parameter1, parameter2,...,timeframe,...,parameterN)
{
switch (timeframe)
{
case 60: TimeFrameSet(inHourly); break;
case 15: TimeFrameSet(in15Minute); break;
case 5: TimeFrameSet(in5Minute); break;
default: break;
}
//here comes the calculations of channels, threshold,
averages, oscillator, etc, everything you need to obtain
signals' conditions

TimeFrameRestore();//AGAIN - it is just an example, by the way - sorry for
illegable layout
switch (timeframe)
{
case 60: channel1=TimeFrameExpand(chan1,inHourly,expandLast);
channel2=TimeFrameExpand(chan2,inHourly,expandLast);
oscillator1=TimeFrameExpand(osc1,inHourly,expandLast);
break;
case 15: //the logic of code the same as above...
break;
case 5: //as above break;
default: channel1=chan;
channel2=chan2;
oscillator1=osc2;
break;
}

//here comes the buy/sell/cover/short/stop conditions and
position sizing, etc
}

Although using #include results in slower code exection, it is a kind of
idea to handle different timeframes system backtest, so I hope that even if
it does not help directly, it will at least inspire you to find your own
solution.

Regards 
Tomasz

--- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com ,
Matthias meridian...@... wrote:

 Hi,
 
 thanks to the contribution of Ed Pottasch, supported by Bruce, I was able
to dig a little deeper into Amibroker coding. Everybody who is interested in
applying multiple systems on the same underlying simultaneously should look
here, great piece of work:
http://finance.groups.yahoo.com/group/AmiBroker-at/message/5349
 
 Thanks Ed, thanks Bruce.
 
 Unfortunately, I stumbled across a couple of questions when backtesting
multiple systems across different timeframes, hope someone can help, sorry
for the post being a bit lenghty.
 
 Both systems are traded on the same underlying, in order to make things
easier for AB (Which is a bit strange) I used the same set of data, just
renamed it. both systems operate on the same timeframe, say 15mins.
 
 
 Question 1: 
 
 I use the same variable percentrisked for both systems. Wanted to
optimize for percent risked (only!, this is NOT shown in the example below),
so to say capital allocated to each system for the smoothest equity curve,
AB keeps crashing... Can I use the same variable name in each sub-section or
are there limits? should I dedicated percentrisked1 to system1 and
percentrisked2 to system2 only? I am not a programmer, but for my
understanding, both variables are local, so AB should not be crashing...?
 
 Is using Setoption in this context appropriate or would it result in
wrong values?
 
 if(Name()==DAX_CFD_day1)
 {
 percentrisked=2.0;
 factor=Optimize(ATR-Factor,8.5,3,12,0.5);
 number=(percentrisked)/(ATR(14)*factor)*20;
 SetPositionSize(number, spsPercentOfEquity);
 SetOption(commissionmode,3);
 SetOption(Commissionamount,1.2);
 SetOption(AllowSameBarExit,True);
 SetOption(ActivateStopsImmediately,True);
 
 .systemlogic here
 }
 
 if(Name()==DAX_CFD_day)
 {
 
 percentrisked=Optimize(Bolli,0.6,0.5,1,0.1); 
 sl=2;//Optimize(sl,2,2,2.5,0.5);//good:6 
 number=(percentrisked/(Ref(ATR(14),-1)*sl))*20; 
 SetPositionSize(number, spsPercentOfEquity); 
 SetOption(commissionmode,3);
 SetOption(Commissionamount,1.2);
 SetOption(AllowSameBarExit,True);
 SetOption(ActivateStopsImmediately,True);
 SetOption(FuturesMode,True);
 SetTradeDelays(1,1,1,1);
 Equity(1); 
 
 ... systemlogic here
 }
 
 
 Question 2:
 
 Both systems above use 15min timeframe. Another system is using 1hr
timeframe and is trading FX. I was not able to re-write the logic so that I
could backtest the 3 systems with AA settings 15min timeframe. Any ideas? I
do have about 8 systems, lowest timeframe is 5min, highest timeframe 4hrs.
That would require a lot of re-writing... Am I alone with my I have too
many-systems Problem or am I missing somehting?
 
 original logic in 1hr timeframe:
 
 percentrisked=0.007; 
 sl=4.5;
 tp=2.5;
 
 number=((percentrisked)/(Ref(ATR(14),-0)*sl)); 
 SetPositionSize(number,spsPercentOfEquity);
 
 SetOption

[amibroker] Backtest multiple systems across multiple timeframes

2010-09-08 Thread Matthias
Hi,

thanks to the contribution of Ed Pottasch, supported by Bruce, I was able to 
dig a little deeper into Amibroker coding. Everybody who is interested in 
applying multiple systems on the same underlying simultaneously should look 
here, great piece of work: 
http://finance.groups.yahoo.com/group/AmiBroker-at/message/5349

Thanks Ed, thanks Bruce.

Unfortunately, I stumbled across a couple of questions when backtesting 
multiple systems across different timeframes, hope someone can help, sorry for 
the post being a bit lenghty.

Both systems are traded on the same underlying, in order to make things easier 
for AB (Which is a bit strange) I used the same set of data, just renamed it. 
both systems operate on the same timeframe, say 15mins.


Question 1: 

I use the same variable percentrisked for both systems. Wanted to optimize 
for percent risked (only!, this is NOT shown in the example below), so to say 
capital allocated to each system for the smoothest equity curve, AB keeps 
crashing... Can I use the same variable name in each sub-section or are there 
limits? should I dedicated percentrisked1 to system1 and percentrisked2 to 
system2 only? I am not a programmer, but for my understanding, both variables 
are local, so AB should not be crashing...?

Is using Setoption in this context appropriate or would it result in wrong 
values?

if(Name()==DAX_CFD_day1)
{
percentrisked=2.0;
factor=Optimize(ATR-Factor,8.5,3,12,0.5);
number=(percentrisked)/(ATR(14)*factor)*20;
SetPositionSize(number, spsPercentOfEquity);
SetOption(commissionmode,3);
SetOption(Commissionamount,1.2);
SetOption(AllowSameBarExit,True);
SetOption(ActivateStopsImmediately,True);

.systemlogic here
}

 if(Name()==DAX_CFD_day)
{
 
percentrisked=Optimize(Bolli,0.6,0.5,1,0.1); 
sl=2;//Optimize(sl,2,2,2.5,0.5);//good:6 
number=(percentrisked/(Ref(ATR(14),-1)*sl))*20; 
SetPositionSize(number, spsPercentOfEquity); 
SetOption(commissionmode,3);
SetOption(Commissionamount,1.2);
SetOption(AllowSameBarExit,True);
SetOption(ActivateStopsImmediately,True);
SetOption(FuturesMode,True);
SetTradeDelays(1,1,1,1);
Equity(1);  

... systemlogic here
}


Question 2:

Both systems above use 15min timeframe. Another system is using 1hr timeframe 
and is trading FX. I was not able to re-write the logic so that I could  
backtest the 3 systems with AA settings 15min timeframe. Any ideas? I do have 
about 8 systems, lowest timeframe is 5min, highest timeframe 4hrs. That would 
require a lot of re-writing... Am I alone with my I have too many-systems 
Problem or am I missing somehting?

original logic in 1hr timeframe:

percentrisked=0.007; 
sl=4.5;
tp=2.5;

number=((percentrisked)/(Ref(ATR(14),-0)*sl)); 
SetPositionSize(number,spsPercentOfEquity);

SetOption(maxopenpositions,1); 


CCIperiod=Optimize(CCI,36,34,40,1); 
CCIthreshold=optimize(CCIthres,89,88,96,1);

MAperiod=Optimize(maperiod,7,6,8,1);

MA1=MA(C,MAperiod);
MA2=MA(Ref(C,-2),MAperiod);

CCIshort=CCI(CCIperiod)=ccithreshold;
CCIbuy= CCI(CCIperiod)=-CCIthreshold;

Buyok=Ref(CCIbuy,-1) AND Cross(MA1,MA2);
Sellok=CCIshort;
Shortok=Ref(CCIshort,-1) AND Cross(MA2,MA1);
Coverok=CCIbuy;

timestart=02;
window=17 
Check=timestart+window; 
timeok=TimeNum()=timestart AND TimeNum()=Check; 

Buy= Buyok AND timeok;
Sell= Sellok;
Short= Shortok AND timeok;
Cover= Coverok;

ApplyStop(stopTypeLoss,stopModePoint,sl*ATR(14)); //9
ApplyStop(stopTypeProfit,stopModePoint,tp*ATR(14)); //1.2

Equity(1);




System2:

percentrisked=0.007; 
sl=4.5;
tp=2.5;

SetOption(maxopenpositions,1); 

CCIperiod=Optimize(CCI,36,34,40,2); 
CCIthreshold=Optimize(CCIthres,97,88,96,2);

MAperiod=   Optimize(maperiod,7,7,9,1);

TimeFrameSet(inHourly);
MA1=MA(C,MAperiod);
MA2=MA(Ref(C,-0),MAperiod);
CCIhr=  CCI(CCIperiod);
ATR1=   ATR(14);
TimeFrameRestore();

number=((percentrisked)/(TimeFrameExpand(Ref(atr1,-0),inHourly)*sl)); 
SetPositionSize(number,spsPercentOfEquity);

CCIshort=TimeFrameExpand(CCIhr,inHourly)ccithreshold;
CCIbuy= TimeFrameExpand(CCIhr,inHourly)-CCIthreshold;


Crossup=Cross(TimeFrameExpand(MA1,inHourly),TimeFrameExpand(Ref(MA2,-2),inHourly));
Crossdown=Cross(TimeFrameExpand(Ref(MA2,-2),inHourly),TimeFrameExpand(MA1,inHourly));

Buyok=Ref(CCIbuy,-5) AND Crossup;
Sellok=CCIshort;
Shortok=Ref(CCIshort,-5) AND Crossdown;
Coverok=CCIbuy;
timestart=2; 
window=17;
Check=timestart+window; 
timeok=TimeNum()=timestart AND TimeNum()=Check; 


Buy=Buyok AND timeok;
Sell= Sellok OR CCIexit;
Short= Shortok AND timeok;
Cover= Coverok OR CCIexit;

ApplyStop(stopTypeLoss,stopModePoint,sl*TimeFrameExpand(Ref(ATR1,-1),inHourly));
 
ApplyStop(stopTypeProfit,stopModePoint,tp*TimeFrameExpand(Ref(ATR1,-1),inHourly));
 

Equity(1);

Thanks a lot for your suggestions,

Matthias



RE: [amibroker] Backtest multiple systems across multiple timeframes

2010-09-08 Thread Matthias K.
Hi Ed,

Good to hear from you again. Basetime interval of the databse is 5min (I
don't use ticks, it s downloaded data from my broker, not IB), but both
systems are 15min timeframe, should be easy to handle.

 Win XP, SP3, 4GB RAM..32bit OS, 

I could create another database, true, but I wanted to backtest the systems
using One/Single - Equitypool logic, all taking their money from ONE
ACCOUNT as done in my RT Trading. Purpose of this is to find out how much
money every sub-system can trade to result in the smoothest equity curve, so
no extensive search or optimization is necessary as the systems are already
profitable.  Having 8 systems, it would require 8-optimization variables,
that's true. But because the systems operate on multiple timeframes, I'm not
sure how to re-write the logic. values/results always differ by more than
10%. or AB crashes when optimizing 'percentrisked'.

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of Edward Pottasch
Sent: Mittwoch, 8. September 2010 22:03
To: amibroker@yahoogroups.com
Subject: Re: [amibroker] Backtest multiple systems across multiple
timeframes

 

  

Matthias,

 

will have a look at your questions in more detail tomorrow. But that
crashing may be caused due to memory problems of your computer rather than
an error in your code.

 

So if your systems are to be used in the 5-min timeframe try using a
database that has its base time interval set to 5 minutes rather than ticks
or 1-minute. So, if you have a data provider then simply create a new
database using for the base time interval 5 minutes

 

that solved a lot of my crash problems,

 

regards, Ed

 

 

 

 

From: Matthias mailto:meridian...@gmx.de  

Sent: Wednesday, September 08, 2010 8:55 PM

To: amibroker@yahoogroups.com 

Subject: [amibroker] Backtest multiple systems across multiple timeframes

 

  

Hi,

thanks to the contribution of Ed Pottasch, supported by Bruce, I was able to
dig a little deeper into Amibroker coding. Everybody who is interested in
applying multiple systems on the same underlying simultaneously should look
here, great piece of work:
http://finance.groups.yahoo.com/group/AmiBroker-at/message/5349

Thanks Ed, thanks Bruce.

Unfortunately, I stumbled across a couple of questions when backtesting
multiple systems across different timeframes, hope someone can help, sorry
for the post being a bit lenghty.

Both systems are traded on the same underlying, in order to make things
easier for AB (Which is a bit strange) I used the same set of data, just
renamed it. both systems operate on the same timeframe, say 15mins.

Question 1: 

I use the same variable percentrisked for both systems. Wanted to optimize
for percent risked (only!, this is NOT shown in the example below), so to
say capital allocated to each system for the smoothest equity curve, AB
keeps crashing... Can I use the same variable name in each sub-section or
are there limits? should I dedicated percentrisked1 to system1 and
percentrisked2 to system2 only? I am not a programmer, but for my
understanding, both variables are local, so AB should not be crashing...?

Is using Setoption in this context appropriate or would it result in wrong
values?

if(Name()==DAX_CFD_day1)
{
percentrisked=2.0;
factor=Optimize(ATR-Factor,8.5,3,12,0.5);
number=(percentrisked)/(ATR(14)*factor)*20;
SetPositionSize(number, spsPercentOfEquity);
SetOption(commissionmode,3);
SetOption(Commissionamount,1.2);
SetOption(AllowSameBarExit,True);
SetOption(ActivateStopsImmediately,True);

.systemlogic here
}

if(Name()==DAX_CFD_day)
{

percentrisked=Optimize(Bolli,0.6,0.5,1,0.1); 
sl=2;//Optimize(sl,2,2,2.5,0.5);//good:6 
number=(percentrisked/(Ref(ATR(14),-1)*sl))*20; 
SetPositionSize(number, spsPercentOfEquity); 
SetOption(commissionmode,3);
SetOption(Commissionamount,1.2);
SetOption(AllowSameBarExit,True);
SetOption(ActivateStopsImmediately,True);
SetOption(FuturesMode,True);
SetTradeDelays(1,1,1,1);
Equity(1); 

... systemlogic here
}

Question 2:

Both systems above use 15min timeframe. Another system is using 1hr
timeframe and is trading FX. I was not able to re-write the logic so that I
could backtest the 3 systems with AA settings 15min timeframe. Any ideas? I
do have about 8 systems, lowest timeframe is 5min, highest timeframe 4hrs.
That would require a lot of re-writing... Am I alone with my I have too
many-systems Problem or am I missing somehting?

original logic in 1hr timeframe:

percentrisked=0.007; 
sl=4.5;
tp=2.5;

number=((percentrisked)/(Ref(ATR(14),-0)*sl)); 
SetPositionSize(number,spsPercentOfEquity);

SetOption(maxopenpositions,1); 

CCIperiod=Optimize(CCI,36,34,40,1); 
CCIthreshold=optimize(CCIthres,89,88,96,1);

MAperiod=Optimize(maperiod,7,6,8,1);

MA1= MA(C,MAperiod);
MA2= MA(Ref(C,-2),MAperiod);

CCIshort=CCI(CCIperiod)=ccithreshold;
CCIbuy= CCI(CCIperiod)=-CCIthreshold;

Buyok=Ref(CCIbuy,-1) AND Cross(MA1,MA2);
Sellok=CCIshort;
Shortok=Ref(CCIshort,-1) AND Cross(MA2,MA1);
Coverok=CCIbuy

RE: [amibroker] Re: Optimizer target with genetic optimization

2010-08-23 Thread Matthias K.
Hi,

Mike is right, just change the target in the settings/walk-forward-tab.
Anyways, you can design your custom metric, too, this is a very valuable
feature, just google amibroker add custom metric. For me, I played along
with the max. k-ratio and min. ulcer-index. My daytrading systems on futures
and FX became much more stable  in out-of-sample tests when optimizing for
k-ratio or Ulcer-Index instead of CAR/MDD, especially when keeping the
in-sample-period very small, say 3-6months, the out of sample to about
3-6months, too. If you're playing with this feature, I d appreciate it if
you could write a little bit about your experience, like what kind of system
you trade, what underlying and of course, your optimization target.

 

Thanks,

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of radmobile_radmobile
Sent: Montag, 23. August 2010 21:48
To: amibroker@yahoogroups.com
Subject: [amibroker] Re: Optimizer target with genetic optimization

 

  

This can be achieved through the custom backtester interface. See:
http://www.amibroker.com/kb/2008/05/19/historical-portfolio-backtest-metrics
/

-RM

--- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com ,
DougOriard d...@... wrote:

 When running one of the genetic optimizers, like cmae or trib, is it
possible to change the optimization target from CAR/MDD to just % profit, or
other target value? 
 
 CAR/MDD is too heavily biased on minimizing MDD. It would be better to
optimize for CAR*(100 - MDD), where MDD is taken as absolute value.
 
 Is there a way to do this?






RE: [amibroker] Re: How to configure CAME to look for a Optimization target MINIMUM

2010-08-09 Thread Matthias K.
Hi,

 

Worked for me! Thanks a lot.

Taking my example, I typed Ulcer-Index-II and it did the run. I didn't
understand why it would not show up in the drop-down menu.

 

Thanks,

 

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of Mike
Sent: Montag, 9. August 2010 08:16
To: amibroker@yahoogroups.com
Subject: [amibroker] Re: How to configure CAME to look for a Optimization
target MINIMUM

 

  

The drop list from which to choose the metric for optimization is an
editable field. Just type in the name (case sensitive) of your metric
instead of choosing from the default list of metrics.

Mike

--- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com ,
Matthias meridian...@... wrote:

 
 
 Hi,
 
 I tried this one out, but when performing Walk-Forward Analysis, I cannot
choose my custom metric as objective function. Effectively, I'd like to
MINIMIZE Ulcer-Index when performing WFA. Portfolio: enable CBT is ticked,
path is specified. Metric appears in the report, and the column is added,
but cannot be chosen from Walk-Forward Optimization Target.
 
 
 SetCustomBacktestProc(); 
 
 if( Status(action) == actionPortfolio ) 
 { 
 bo = GetBacktesterObject(); 
 
 bo.Backtest(); // run default backtest procedure 
 
 st = bo.GetPerformanceStats(0); // get stats for all trades 
 
 Ulcer = -1*st.GetValue(UlcerIndex);
 
 
 bo.AddCustomMetric( Ulcer-Index-II,Ulcer ); 
 } 
 
 
 Also checked the links where it states:
 
 The Optimization target field defines the optimization raport COLUMN
NAME that
 will be used for sorting results and finding the BEST one. Any built-in
column can be used
 (as appears in the optimization output), or you can use any custom metric
that you define
 in custom backtester. The default is CAR/MDD, you can however select any
other built-in metric from the combo.
 You can also TYPE-IN any custom metric that you have added via custom
backtester interface.
 
 
 Any suggestions?
 
 
 Matthias
 
 
 
 
 
 
 --- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com ,
Mike sfclimbers@ wrote:
 
  Add your own custom metric to be used as the optimization target. Simply
calculate your metric as the negative of your intended metric. The result
will be that originally large values become smaller (i.e. more negative) and
originally small values become larger (i.e. less negative).
  
  Refer to custom metrics for more detail:
  http://www.amibroker.com/guide/a_custommetrics.html
  
  Set custom target on WFA settings (applies to regular optimization too,
not just walk forward):
 
http://www.amibroker.com/kb/2008/02/12/getting-started-with-automatic-walk-f
orward-optimization/
  
  Mike
  
  --- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com ,
elizabeth19852002 elizabeth.kennedy@ wrote:
  
   Hello all,
   
   I would appreciate if someone can please tell me how to configure
optimizations like CAME so that it looks for a MINIMUM (as opposed to a
Maximum) of an optimization target (such as user defined objective
function).
   
   Just by adding OptimizerSetEngine(cmae); in AFL and setting the
Optimization target in the Walkforward tab does not tell it to look for a
MINIMUM or MAXIMUM of the optimization target during optimization ???
   
   Thanking you
   
   Liz
  
 






[amibroker] Re: How to configure CAME to look for a Optimization target MINIMUM

2010-08-08 Thread Matthias


Hi,

I tried this one out, but when performing Walk-Forward Analysis, I cannot 
choose my custom metric as objective function. Effectively, I'd like to 
MINIMIZE Ulcer-Index when performing WFA. Portfolio: enable CBT is ticked, 
path is specified. Metric appears in the report, and the column is added, but 
cannot be chosen from Walk-Forward Optimization Target.


SetCustomBacktestProc(); 

if( Status(action) == actionPortfolio ) 
{ 
bo = GetBacktesterObject(); 

bo.Backtest(); // run default backtest procedure 

st = bo.GetPerformanceStats(0); // get stats for all trades 

Ulcer = -1*st.GetValue(UlcerIndex);


bo.AddCustomMetric( Ulcer-Index-II,Ulcer ); 
} 


Also checked the links where it states:

The Optimization target field defines the optimization raport COLUMN NAME 
that
will be used for sorting results and finding the BEST one. Any built-in column 
can be used
(as appears in the optimization output), or you can use any custom metric that 
you define
in custom backtester. The default is CAR/MDD, you can however select any other 
built-in metric from the combo.
You can also TYPE-IN any custom metric that you have added via custom 
backtester interface.


Any suggestions?


Matthias






--- In amibroker@yahoogroups.com, Mike sfclimb...@... wrote:

 Add your own custom metric to be used as the optimization target. Simply 
 calculate your metric as the negative of your intended metric. The result 
 will be that originally large values become smaller (i.e. more negative) and 
 originally small values become larger (i.e. less negative).
 
 Refer to custom metrics for more detail:
 http://www.amibroker.com/guide/a_custommetrics.html
 
 Set custom target on WFA settings (applies to regular optimization too, not 
 just walk forward):
 http://www.amibroker.com/kb/2008/02/12/getting-started-with-automatic-walk-forward-optimization/
 
 Mike
 
 --- In amibroker@yahoogroups.com, elizabeth19852002 elizabeth.kennedy@ 
 wrote:
 
  Hello all,
  
  I would appreciate if someone can please tell me how to configure 
  optimizations like CAME so that it looks for a MINIMUM (as opposed to a 
  Maximum) of an optimization target (such as user defined objective 
  function).
  
  Just by adding   OptimizerSetEngine(cmae); in AFL and setting the 
  Optimization target in the Walkforward tab does not tell it to look for a 
  MINIMUM or MAXIMUM of the optimization target during optimization ???
  
  Thanking you
  
  Liz
 





RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo Analysis

2010-07-29 Thread Matthias K.
Hi Lionel,

 

With “this book”, I suppose you mean this one: 
http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8
 
http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8s=booksqid=1280174971sr=8-1
 s=booksqid=1280174971sr=8-1

I was talking to Mike and he said that Tharp uses MC for position sizing in his 
book “the definitive guide to position sizing”. That’s why Mr. Tharp “entered 
the discussion”. I just wanted to add a critical review on his new book 
“supertrader”. So, I guess I don’t understand your question. The books cannot 
really be compared. 

 

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of 
Lionel Issen
Sent: Donnerstag, 29. Juli 2010 03:29
To: amibroker@yahoogroups.com
Subject: RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo 
Analysis

 

  

Thanks. How does this book compare with Van Tharp’s book?

 

http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8
 
http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8s=booksqid=1280174971sr=8-1
 s=booksqid=1280174971sr=8-1



RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo Analysis

2010-07-29 Thread Matthias K.
MC = Monte Carlo

 

Cheers,

 

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of 
Lionel Issen
Sent: Freitag, 30. Juli 2010 02:02
To: amibroker@yahoogroups.com
Subject: RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo 
Analysis

 

  

Hi Matthias:

 

Thanks  for this information.

 

 Excuse my ignorance, but what does MC mean?

 

Lionel

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of 
Matthias K.
Sent: Thursday, July 29, 2010 10:49 AM
To: amibroker@yahoogroups.com
Subject: RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo 
Analysis

 

  

Hi Lionel,

 

With “this book”, I suppose you mean this one: 
http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8
 
http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8s=booksqid=1280174971sr=8-1
 s=booksqid=1280174971sr=8-1

I was talking to Mike and he said that Tharp uses MC for position sizing in his 
book “the definitive guide to position sizing”. That’s why Mr. Tharp “entered 
the discussion”. I just wanted to add a critical review on his new book 
“supertrader”. So, I guess I don’t understand your question. The books cannot 
really be compared. 

 

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of 
Lionel Issen
Sent: Donnerstag, 29. Juli 2010 03:29
To: amibroker@yahoogroups.com
Subject: RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo 
Analysis

 

  

Thanks. How does this book compare with Van Tharp’s book?

 

http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8
 
http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8s=booksqid=1280174971sr=8-1
 s=booksqid=1280174971sr=8-1





RE: [amibroker] Multiple Time Frames

2010-07-29 Thread Matthias K.
Hi, 

 

There's lots of mistakes in this code:

1.   You're missing timeframeexpand

2.   IIF cannot be use like this, I wonder if it returned you a result
at all

 

Ok. I'm not sure about your Stochastic-Thingie, but you should be able to
customize my example to your needs. Furthermore check the tutorial.
http://www.amibroker.com/guide/h_timeframe.html

5min-Chart, your smallest interval, could be anything, 15min, 1hr, I take
5min for now. I wanna buy if the Close (5min) is greater than EMA(C,200)
indaily and only before 12 o'clock in the morning. 

 

 

TimeFrameSet(inDaily);

EMA1=EMA(C,200);

TimeFrameRestore();

 

Buy=IIf(CTimeFrameExpand(EMA1,inDaily) AND TimeNum()=12,1,0);

Sell=0;

 

Anyways, you don't really need IIF here. Works like this, too

 

TimeFrameSet(inDaily);

EMA1=EMA(C,200);

TimeFrameRestore();

 

Buy=CTimeFrameExpand(EMA1,inDaily) AND TimeNum()=12;

 

Sell=0;

 

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of Jonathan Lee
Sent: Dienstag, 27. Juli 2010 19:47
To: amibroker@yahoogroups.com
Subject: [amibroker] Multiple Time Frames

 

  

Hi amibroker experts,

 

I'm a little stuck with multiple time frames - and was hoping someone could
assist. It's probably a straight forward solution as I'm pretty much a
newbie at this.

 

I've got a basic oscillator (similar to stochastics) in which I have
determined that 30 is oversold, 70 is overbought and 50 at mid range. i'm
using the higher time frame as a condition, so looking at the hourly chart,
I only want a buy signal to be actioned if the daily chart (%K and %D) is
less than the mid range (50).

 

I put all my daily parameters between:

TimeFrameSet (inDaily) and TimeFrameRestore ();

 

And my buy/sell instruction (in the hourly setting) is as follows:

 

IIf((DailySK=DailyMid AND DailySD=DailyMid),Buy=SK=Lower AND SD=Lower
AND Cross(SK,SD),0);

IIf((DailySK=DailyMid AND DailySD=DailyMid),Sell=SK=Upper AND SD=Upper
AND Cross(SD,SK),0);

Short=Cover=0;

 

For some reason I am getting results which ignore the higher time frame? 

Much appreciated.

Jonathan 

 

 





RE: [amibroker] Optimize Time Parameters

2010-07-28 Thread Matthias K.
Hi,

I'm using this. It's pretty much self-explanatory. Works based on hours.
Depending on which data you use, the timestamp might be different. So to say
timestart might be 055900 instead of 06. Watch out for Fridays, too, if
you don't wanna hold the trader over the weekend.

 

timestart=06;//Optimize(timestart,06,00,23,1);

window=08;//Optimize(windowlength,07,04,10,1);

Check=timestart+window;

timeok=TimeNum()=timestart AND TimeNum()=Check;

 

Greetings,

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of pcmoxon
Sent: Mittwoch, 28. Juli 2010 17:11
To: amibroker@yahoogroups.com
Subject: [amibroker] Optimize Time Parameters

 

  

Hi,

I am working on an intraday system and want to optimize the trading hours
the system should trade. I have a Start Time parameter (using ParamTime) and
I would like to optimize the system using this field.

Does anyone know how to optimize using Time fields? Any examples you know of
would really help.

Kind Regards,
Pete





RE: [amibroker] Re: Trading Systems, Position Sizing and Monte Carlo Analysis

2010-07-28 Thread Matthias K.
Hi,

Thanks Mike for your explanation and the link. The definite guide to
position sizing is the only book I'm missing in my van Tharp collection,
looks like just found my next bday present, hehee. Just to make this
complete, the new Supertrader book is pretty lame in my opinion, nothing
really new, just a little bit of everything from Tharp. I shall look up on
Vince, thanks for the info.

 

Following up with the previous posts we need to look outside the samples to
get the full pictures

I'd like to hear a little more on that, too, if you're willing to share.

 

Thanks,

 

Matthias

 

 

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of mkecera
Sent: Mittwoch, 28. Juli 2010 17:48
To: amibroker@yahoogroups.com
Subject: [amibroker] Re: Trading Systems, Position Sizing and Monte Carlo
Analysis

 

  


Yes. That's what I was trying to point out. I would be interested to hear
more about we need to look outside the samples to get the full pictures if
you would like to share.

Best regards,

MK

--- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com ,
paultsho paul.t...@... wrote:

 I think the emphasis of MK's comments is about the use (or misuse) of the
phase monte carlo simulation to equate to random rearrangement of trades and
its possible ramification. Monte Carlo simulation is based on ARTIFICALLY
simulating data points by recreating the a chance process, running it many
times, and directly observing the results -
http://www3.wabash.edu/econometrics/EconometricsBook/chap9.htm  bootstrap
is resampling repeatedly and randomly from an original, initial sample -
http://www3.wabash.edu/econometrics/EconometricsBook/chap23.htm. While
leaving the discussion on assumptions aside (I'll say more when I get a bit
more time). One of the problems of equating bootstrapping with monte carlo
is that incorrect conclusions are also drawn about the methodology. I do not
believe resampling of trades gives us a reliable picture about the behaviour
of a trading system. We should all be familiar with rearranging the deck
chairs on the Titanic does no good at all. Similarly, I think we need to
look outside the samples to get the full pictures.





RE: [amibroker] Re: Trading Systems, Position Sizing and Monte Carlo Analysis

2010-07-27 Thread Matthias K.
Hi,

 

Mike, you suggested

 

Ralph Vince
- The Handbook of Portfolio Mathematics: Formulas for Optimal Allocation  
Leverage (Wiley Trading 2007)

- The Leverage Space Trading Model: Reconciling Portfolio Management Strategies 
and Economic Theory (Wiley Trading 2009)

 

Did you read them? Could you give me a brief summary, something a little bit 
more critical than Amazon’s praises to the sky? I like Vince’s work, guess I 
shall read them, I just don’t like the term economic theory. But before this 
topic falls asleep:

If I got it right: This one is about trading one system on a market-portfolio, 
than figuring out some statistics etc. What I’d like to read up on is something 
like a TRADING SYSTEM PORTFOLIO on 1 market, so to say not pick the markets 
scientifically, but the systems.

 

Additionally, my comments on MC are incomplete because I didn’t dig very deep 
into the material. I am aware of the methods you described below, but still I 
don’t really believe it’s useful. What’s the use of knowing average 
performance, best performance, worst performance, etc.? If you have that info, 
do you base something on it, say position sizing, emergency system stop? My 
walkforward oos is something that I do trust more, guess that’s my opinion.

 

 

 

 

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of 
Mike
Sent: Dienstag, 27. Juli 2010 00:02
To: amibroker@yahoogroups.com
Subject: [amibroker] Re: Trading Systems, Position Sizing and Monte Carlo 
Analysis

 

  

Books that you might be interested in:

Ralph Vince
- The Handbook of Portfolio Mathematics: Formulas for Optimal Allocation  
Leverage (Wiley Trading 2007)

- The Leverage Space Trading Model: Reconciling Portfolio Management Strategies 
and Economic Theory (Wiley Trading 2009)

Your comments on Monte Carlo are incomplete. Monte Carlo is not just changing 
the the order of trades. Monte Carlo can also be used to treat existing trades 
as a pool of trades from which a greater number of trades may be sampled in 
order to project a longer term equity curve.

For example, if you have a collection of trades that you feel adequately 
represent the range of trades that your system will generate, you can randomly 
draw some number of trades (with replacement) from the pool to generate 
thousands of equity curves (e.g. draw 100 trades from a pool of 30). You may 
then analyze the resulting equity curves to get such information as average 
performance, best performance, worst performance, etc.

Mike

--- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com , 
Matthias K. meridian...@... wrote:

 Hi,
 
 
 
 Indeed this is a very interesting topic. Many thanks go to Howard Bandy, it 
 is literally a must read when working with Amibroker. I’m curiously waiting 
 for the new one.
 
 
 
 Regarding System Design and Position Sizing:
 
 Well, I believe that there are a lot of books out there, but different 
 authors really do mix up terminology, so this is how I interpret it:
 
 
 
 Position sizing
 
 Tells you how much, e.g. how many contracts or shares one should buy, Howard 
 just mentioned 2 algos, fixed fraction and fixed ration. Ralph Vince’s book 
 is a must read on this, however, it’s not quite easy going. Furthermore, 
 there’s martingale and antimartingale, whereas martingale pretty much 
 means: the more you lose, the more you bet. I believe it’s a sure-fire way 
 to the poorhouse, that’s why I use ALWAYS anti-martingale. No black swans 
 welcome in my trading.
 
 
 
 Risk management
 
 Obivously, there’s a clear overlap with position sizing, but still I 
 believe it’s meant to be a little different. Say you have a system with a 
 plugged in position sizing algo. You backtest it and you’ll have an 
 estimate of the drawdown. Obviously, you will want to adjust position size so 
 that you can stomach the drawdown. But as a safety measure, you might plug in 
 another strategy. It might be an equity MA-Crossover, it might be something 
 psychological (a divorce, an illness), it might also be a safety stop due to 
 increased market volatility / markets crash.
 
 Remember to always measure drawdown in percentage terms, e.g. Tradestation 
 Strategy Report is pretty useless, because it only shows drawdown as an 
 absolute figure so it requires Excel to actually calculate drawdown in 
 percentage terms. Also CAR is calculated correctly in AB, I’ve seen other 
 software, costing 2k€, still calculating CAR wrong (10 times 10% per annum 
 is NOT 100%)
 
 
 
 Portfolio Management
 
 Hahaa, I believe this is where a few gold bucks a buried. Portfolio in terms 
 of which markets to trade has been discussed in the literature, still this is 
 a very specialized topic already. There not many books found on this, 
 that’s why I spend so much time thinking about it: Nothing to be found 
 means a lot to be made and understanding it in great detail might give me/you 
 a larger edge. Especially

RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo Analysis

2010-07-26 Thread Matthias K.
 
estimate of a historic drawdown, but I achieve the same by multiplying my 
non-monte-carlo-drawdown with say 1.5…

 

 

Greetings from Germany,

 

Matthias

 

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of 
Howard B
Sent: Montag, 26. Juli 2010 16:33
To: amibroker@yahoogroups.com
Subject: Re: [amibroker] Trading Systems, Position Sizing and Monte Carlo 
Analysis

 

  

Hi Sohamdas --

In my opinion, this is definitely a topic that deserves discussion in the 
AmiBroker forum.

What position sizing should be used during backtests?

If you will be evaluating each trade for its characteristics -- entry 
efficiency, exit efficiency, and so forth, then each trade should be the same 
size.  For stocks and ETFs that means the same dollar amount.  For futures that 
means the same number of contracts.

If you will be comparing equity growth over a period of time to other 
alternatives, then you will want position sizing and / or compounding to some 
degree.  For example, if you want to compare the results of a trading system to 
buy and hold, you will want to take the same size position at the beginning if 
the test period for each alternative, then compare equity smoothness, growth, 
drawdown, etc.

If you are planning to use aggressive position sizing, there are several things 
to consider.
1.  I cannot state it too often -- your system must have a positive expectancy 
measured on strictly out-of-sample results.  You absolutely cannot use 
in-sample results to estimate the likely future performance of a trading system 
in any event.  And if aggressive position sizing is based on in-sample results, 
you will go bankrupt.
2.  Traders should have a business plan in place.  They should know when to 
quit -- either when they have enough that they no longer need to trade, or when 
they have lost so much that they can no longer trade or realize that they 
should pick another profession. 
3.  Aggressive position sizing depends on having:
A.  Positive expectancy.
B.  Understanding of risk.  Both the risk that is acceptable for each trade 
from the account, and the risk associated with the trading system.  Most 
trading systems have higher risk per trade than the account risk allows, so 
even taking a position that is everything you can afford to buy is aggressive.  
C.  The ability to use leverage.  Brokers allow use of margin, and some ETFs 
have leverage.  By using these, it is possible to get 12 to 20 times leverage 
trading stocks and ETFs in an ordinary brokerage account.  
D.  Frequent trading, because that provides frequent compounding.  For most 
trading systems, the final equity of an account is a multiple of the initial 
equity that can be computed from:
terminal_equity = (1 + expectancy) ^ number_of_trades
where expectancy is the average percentage gain per trade.

There are two general schemes for aggressive position sizing.  As you dig into 
the math, you will see that they are closely related.
The first is fixed fraction, popularized by Ralph Vince.
The second is fixed ratio, popularized by Ryan Jones.
Both men have written books and papers describing their methods, and you can do 
an Internet search on each phrase and get a lot of information.

The essence of both methods is to increase position size when the system is 
operating profitably.  In gambling terminology, you are betting the run of the 
table.  When winning, increase; when losing, pull back.  Both of these are 
betting schemes called anti-martingale.  

Ralph Vince has also popularized the notion of optimal f -- that fixed 
fraction that should be bet on each play to maximize the terminal equity.  The 
fraction of the account used for each play is determined by the largest 
anticipated drawdown or trade loss.  He, and everyone else who is working with 
real money, shows that the fraction bet on each play Must be less than optimal 
f if the account is to remain solvent.  In fact, the fraction must be much less 
than optimal f if the account is avoid large drawdowns.  Trading at optimal f 
essentially guarantees drawdowns in the 80 percent range.  

Ryan Jones essentially creates two sub-accounts.  One is the original stake, 
say $100,000.  The other is the profits from trading.  Ryan waits until there 
are some profits, then uses a high percentage of the profits for each trade.

The two methods converge mathematically.  Some traders prefer to begin using 
one method, then switch to the other as profits accumulate. 

Before you consider using an aggressive position sizing scheme, and buying all 
the stock you can afford is aggressive, please read my other comments in both 
this forum and Aussie Stock Forums related to trading system development and 
position sizing.  And read both Vince's and Ryan's books, and other material 
you can find on the Internet.

The input to the simulators that model either fixed fraction or fixed ratio 
need is a list of closed trade results.  These are individual trades, each

RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo Analysis

2010-07-26 Thread Matthias K.
Well, it’s written in English, otherwise it wouldn’t be very useful to post it 
;) Try this one instead.

http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8
 
http://www.amazon.com/Trading-Systems-Optimisation-Portfolio-Construction/dp/1905641796/ref=sr_1_1?ie=UTF8s=booksqid=1280174971sr=8-1
 s=booksqid=1280174971sr=8-1

If living in the States, I believe you could order it from amazon UK, I’m sure 
they have it in stock there.

Just please be aware that it scratches this topic (multiple systems portfolio, 
portfolio composition, etc.)  only. Half of the book is “beginner’s” talk, like 
where to start from and so forth. The remaining rest is, very very good food 
for thought. I don’t quite understand the critics in Amazon. (Ok, ok enough 
advertisement J )

 

 

Maybe this one is worth adding (Stridsman):

http://www.amazon.com/Trading-Systems-That-Work-Evaluating/dp/007135980X/ref=sr_1_1?ie=UTF8
 
http://www.amazon.com/Trading-Systems-That-Work-Evaluating/dp/007135980X/ref=sr_1_1?ie=UTF8s=booksqid=1280175191sr=1-1
 s=booksqid=1280175191sr=1-1

This book is outstanding from the very page onwards. But it deals with 
“long-term” trendfollowing, futures being the only instrument traded (I don’t 
have the money to actively trade say 20 futures markets long-term. To do so, 
you need 2.5M€ or about 3m$, that’s what I estimated) The methodologies inside 
are so much worth the money. 

 

 

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of 
Lionel Issen
Sent: Montag, 26. Juli 2010 22:01
To: amibroker@yahoogroups.com
Subject: RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo 
Analysis

 

  

Your link for 

Trading Systems: A New Approach to System Development and Portfolio 
OptimisationTrading Systems: A New Approach to System Development and Portfolio 
Optimisation

led to Amazon Germany. I couldn’t find any US sellers. Is the book only 
published in German,  is it also available in English?

 

Lionel Issen

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf Of 
Matthias K.
Sent: Monday, July 26, 2010 2:19 PM
To: amibroker@yahoogroups.com
Subject: RE: [amibroker] Trading Systems, Position Sizing and Monte Carlo 
Analysis

 

  

Hi,

 

Indeed this is a very interesting topic. Many thanks go to Howard Bandy,  it is 
literally a must read when working with Amibroker. I’m curiously waiting for 
the new one.

 

Regarding System Design and Position Sizing:

Well, I believe that there are a lot of books out there, but different authors 
really do mix up terminology, so this is how I interpret it:

 

Position sizing

Tells you how much, e.g. how many contracts or shares one should buy, Howard 
just mentioned 2 algos, fixed fraction and fixed ration. Ralph Vince’s book is 
a must read on this, however, it’s not quite easy going. Furthermore, there’s 
martingale and antimartingale, whereas martingale pretty much means: the more 
you lose, the more you bet. I believe it’s a sure-fire way to the poorhouse, 
that’s why I use ALWAYS anti-martingale. No black swans welcome in my trading.

 

Risk management

Obivously, there’s a clear overlap with position sizing, but still I believe 
it’s meant to be a little different. Say you have a system with a plugged in 
position sizing algo. You backtest it and you’ll have an estimate of the 
drawdown. Obviously, you will want to adjust position size so that you can 
stomach the drawdown. But as a safety measure, you might plug in another 
strategy. It might be an equity MA-Crossover, it might be something 
psychological (a divorce, an illness), it might also be a safety stop due to 
increased market volatility / markets crash.

Remember to always measure drawdown in percentage terms, e.g. Tradestation 
Strategy Report is pretty useless, because it only shows drawdown as an 
absolute figure so it requires Excel to actually calculate drawdown in 
percentage terms. Also CAR is calculated correctly in AB, I’ve seen other 
software, costing 2k€, still calculating CAR wrong (10 times 10% per annum is 
NOT 100%)

 

Portfolio Management

Hahaa, I believe this is where a few gold bucks a buried. Portfolio in terms of 
which markets to trade has been discussed in the literature, still this is a 
very specialized topic already. There not many books found on this, that’s why 
I spend so much time thinking about it: Nothing to be found means a lot to be 
made and understanding it in great detail might give me/you a larger edge. 
Especially a scientific approach that is not based on gut-feel, is missing. 
This is what I am currently working on: Portfolio Management in terms of 
Trading Systems. So to say, have a trading systems farm, probably 3-5 systems 
on one underlying to have a very smooth equity curve. This includes 
diversification across a) methodology (Mean Reversion, Trendfollowing, 
Breakouts,etc.) and b) timeframe (day-trading, swing trading

RE: [amibroker] Help with DDE connections using TOS

2010-07-23 Thread Matthias K.
Hi,

 

Did you try putting a symbol into realtime quote list by type in symbol
(use the symbol's name of your DDE provider). Other than that, try to look
up in the documentation of TOC, not sure what it stands for/where it comes
from. NO backfill available via DDE.

 

Matthias

 

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of bar607
Sent: Donnerstag, 22. Juli 2010 23:11
To: amibroker@yahoogroups.com
Subject: [amibroker] Help with DDE connections using TOS

 

  

Hi,

I configured the DDE connection according to this post with people that have
successful done it 
http://finance.groups.yahoo.com/group/amibroker/message/149673

I did exactly as it stated but I still can NOT connect through DDE.

Can anyone help me?

Thanks,
Pin





RE: [amibroker] Re: Help with DDE connections using TOS

2010-07-23 Thread Matthias K.
Hi,

 

Backfill means filling your chart with historical data for a specific
period. All you can do with DDE is to get CURRENT realtime quotes, store
them and good. If you switch off your computer on Monday, turn it on on
Tuesday, you won't have data for Monday, no way to get it from your DDE
source/interface.

 

However, you can import historical quotes MANUALLY if your server has
historical data available in ASCII format, e.g., and you can download them.
With your provider, this seems to be the case, but it's quite a hassle
updating the database manually if trading say, 1min charts.

 

An elegant solution is the COM interface, that several providers, e.g.
Esignal offer. AB has a dedicated Plug-In for each provider in the list.
Backfilling  data with the COM/RT-plugin is not a problem, however, it'll
require you to spend a little money on a monthly base.

 

Have a nice weekend,

 

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of bharat
Sent: Freitag, 23. Juli 2010 19:53
To: amibroker@yahoogroups.com
Subject: [amibroker] Re: Help with DDE connections using TOS

 

  

Dear Matthias

You have written that no backfill available via DDE.But does it apply to
server which has data available?I think server of TBMX has 14 years data
stored on it,because I am able to draw chart for 14 yeas data. 

--- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com ,
Matthias K. meridian...@... wrote:

 Hi,
 
 
 
 Did you try putting a symbol into realtime quote list by type in
symbol
 (use the symbol's name of your DDE provider). Other than that, try to look
 up in the documentation of TOC, not sure what it stands for/where it comes
 from. NO backfill available via DDE.
 
 
 
 Matthias
 
 
 
 
 
 From: amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com
[mailto:amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com ] On
Behalf
 Of bar607
 Sent: Donnerstag, 22. Juli 2010 23:11
 To: amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com 
 Subject: [amibroker] Help with DDE connections using TOS
 
 
 
 
 
 Hi,
 
 I configured the DDE connection according to this post with people that
have
 successful done it 
 http://finance.groups.yahoo.com/group/amibroker/message/149673
 
 I did exactly as it stated but I still can NOT connect through DDE.
 
 Can anyone help me?
 
 Thanks,
 Pin






[amibroker] Who is trading more than 5 Systems simultaneously with AB?

2010-07-21 Thread Matthias
Hi,

I'm looking for an approach to run more than only 1 or 2 systems automated with 
AB. Is there someone in here who can offer advice(hardware, coding, etc.) or 
has faced the same problem?

I have read up on AT-programming and I did grasp the concept, but after going 
through this forum and a couple of emails to the support, I cannot really find 
a workable solution. Maybe I'm understanding something wrong, but combining 2 
Systems in one AFL seems pretty tricky already.

What happens if I get a long and short at the same bar when trading only one 
underlying!? solutions that were offered are not useful: Position-Pool which 
sums up the positions before sending them to IB

Not to mention the debugging of a 4-Systems-AT-AFL. 

So, I'm willing to do whatever it takes - please don't get me wrong - if the 
idea is worthwhile pursuing, but I simply don't have a clear-cut 
approach/solution for this.

Obviously finding some good systems that complement each other is tricky 
already, spending hours n hours of coding just to combine and debug  more than 
2 systems, I'm sorry but it'll give me a serious headache.

I mean, how would it be like if I had to combine 10 Systems into 1 AFL?

Guess the outcome would kinda like look scary.


Is running several instances of AB connected to one IB account a good idea?

Thanks in advance,
Greetings from Germany,

Matthias





[amibroker] Re: Who is trading more than 5 Systems simultaneously with AB?

2010-07-21 Thread Matthias
Sorry, this was meant to be in the Autotrading Forum, mixed it up. Anyways, 
it's in this one and the at-forum now. Didn't mean to be pushy.

M



RE: [amibroker] Backtest Report Long/Short trades columns?

2010-07-21 Thread Matthias K.
Hi,

It's very hard to understand the system's logic only by numbers. But as a
matter of fact you identified the problem already: when you're testing long
only, the shorts are skipped, thus it'll result in a very different equity
curve as compared to the result when trading long and short together. So
far, if everything went right, you just figured out the difference of
trading a long-only system and a short-only system.

 

If trading stocks, one might consider the long-side only because the indices
and stocks sort of have a long-bias. In order to smoothen your equity curve,
you might want to combine a short and a long system. The result is something
like you're showing here.  It'll pretty much enable you to make money in
both bull and bear markets and ideally smoothens out the equity curve and
reduces drawdowns and flat periods. Looks good to me if your coding has been
right and doesn't look into the future.

 

Always:

 

CAR/MDD ratio: above 1,5 over 10 years time is outstanding, as it's a risk
adjusted measure, it'll equal/weigh up profits versus losses|drawdown and
will not consider net profit only

 

To sum it up: the more trades you have, the longer your backtesting period
is, the higher your CAR/MDD ratio: the better your system. Don't forget to
include commissions/ spreads, anyhow. They might deteriorate your big
picture. Especially with mid-caps.

 

A good custom backtest metric might be a combination of number of trades and
CAR/MDD, so to say, make 50 Trades per year and still give a CAR/MDD ratio
above 1.

 

Greetings

 

M

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of Ron
Sent: Donnerstag, 22. Juli 2010 06:31
To: amibroker@yahoogroups.com
Subject: [amibroker] Backtest Report Long/Short trades columns?

 

  

I have a strategy that over time is either long or short but not both at the
same time. I'm having difficulty understanding the Long and Short trades
columns in the back test report when I run the back test in Long and Short
mode.

Long only backtest gives (Net Profit 458.76%)

Initial capital 10.00 10.00 10.00 
Ending capital 558757.12 558757.12 106586.98 
Net Profit 458757.12 458757.12 6586.98 
Net Profit % 458.76 % 458.76 % 6.59 % 
Exposure % 38.28 % 38.28 % 0.00 % 
Net Risk Adjusted Return % 1198.47 % 1198.47 % N/A 
Annual Return % 30.78 % 30.78 % 1.00 % 
Risk Adjusted Return % 80.42 % 80.42 % N/A 

Short only backtest gives (Net Profit 75.89%)

Initial capital 10.00 10.00 10.00 
Ending capital 175889.18 106586.98 175889.18 
Net Profit 75889.18 6586.98 75889.18 
Net Profit % 75.89 % 6.59 % 75.89 % 
Exposure % 28.44 % 0.00 % 28.44 % 
Net Risk Adjusted Return % 266.88 % N/A 266.88 % 
Annual Return % 9.21 % 1.00 % 9.21 % 
Risk Adjusted Return % 32.38 % N/A 32.38 % 

The Long  Short backtest gives,

Initial capital 10.00 10.00 10.00 
Ending capital 921758.81 712441.67 315904.12 
Net Profit 821758.81 612441.67 215904.12 
Net Profit % 821.76 % 612.44 % 215.90 % 
Exposure % 66.78 % 38.28 % 28.50 % 
Net Risk Adjusted Return % 1230.56 % 1599.91 % 757.56 % 
Annual Return % 41.40 % 35.84 % 19.65 % 
Risk Adjusted Return % 62.00 % 93.62 % 68.96 % 

Notice the Long Net Profit is 612.44% and Short is 215.90% which is quite a
bit different then when I ran them independently. Other columns are
different as well but I'll focus on Net Profit % for now.

I expect there is some compounding thing happening here but if someone asked
me I couldn't explain it. Does anyone out there have a explanation.

Thanks in advance,

Ron





RE: [amibroker] Still trying to combine systems

2010-07-19 Thread Matthias K.
Hi,

 

Any news on your approach? Just ran through the afl online lib and found an
idea from Paul Ho called something like “testing multiple systems” without
going into CBT. Maybe you wanna give it a try…

 

Greets from Germany…

 

M

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of Gonzaga
Sent: Mittwoch, 14. Juli 2010 17:49
To: amibroker@yahoogroups.com
Subject: [amibroker] Still trying to combine systems

 

  

Hi
I have been fighting with AFL to write a sample program that let us combine
two systems, as I told in a recent thread.
I haven´t been able.
The idea is easy: two type of buy conditions, one in the crossing of two
averages, the other after falling four bars, using EOD bars.
Both systems uses the same pool of money, and are PORTFOLIO SYSTEMS, buying
as far as ten stocks, 10% of the money every purchase.

THE BUY condition is easy to combine. But I have to tell AFL that if the
last BUY as been using the First condition, the SELL has to be checked with
the crossing of the averages again.
And if the last BUY condition as been the second, the SELL condition has to
be another one. (2 bars away from buying day).
After trying it many times without using Custom backtester interface, I
think the only way is using backtester interface.
So I write the exact code, so anybody can test it and fill the custom
backtest part..
I think it should be easy; the problem is that I don't really understand the
logic of the custom backtester, so I don't know what to do
Any suggestion will be very very much appreciated..

//BEGGINING OF CODE
posQty=Param(Posiciones simultaneas,10,1,20,1);
CapMinimo=Param(Cap minimo,2,1,200,5);
SetOption(InitialEquity, 10 ); 
SetOption(AllowPositionShrinking, True ); 
SetOption(MaxOpenPositions, PosQty );
SetOption (accountmargin,100);
PositionSize = -100/(posqty); 
Buy=Sell=0;
SetTradeDelays(1,1,1,1);

//FIRST SYSTEM---
Buy1= Cross(MA(C,15),MA(C,70));
BuyPrice1=Open;
SellA=Cross(MA(C,70),MA(C,15));
SellPriceA=Open;

//SECOND SYSTEM---
Buy2= CO AND Ref(C,-1)Ref(O,-1) AND Ref(C,-2)Ref(O,-2) AND
Ref(C,-3)Ref(O,-3);
SellB= Ref(Buy,-2);

//BUY-
Buy=IIf(Buy1,True,IIf(Buy2,True,False));
BuyPrice=Open;
nombre1=Name();

typeBuy=IIf(Buy1,1,IIf(Buy2,2,0));//if buy1, array 'typebuy' is 1. If Buy2,
is 2. Else is 0
n=BarsSince(Buy);

//NEXT TWO SENTENCES DOES NOT WORK
//Sell= IIf( Ref(typebuy,-n)==1, Cross(MA(C,15),MA(C,70)),False);
//Sell= IIf( NOT Sell AND Ref(Buy2,-n), Ref(Buy,-2),False);

//INSTEAD, USE OF CUSTOMBACKTESTER
SetCustomBacktestProc();
if (Status(action) == actionPortfolio) {
bo = GetBacktesterObject(); // Get backtester object
bo.PreProcess(); // Do pre-processing (always required)
for (i = 0; i  BarCount; i++) // Loop through all bars
{
for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
{ 
if (sig.isentry() AND Buy1[i])

//m 

} // End of for loop over signals at this bar
bo.ProcessTradeSignals(i); // Process trades at bar (always required)
} // End of for loop over bars
bo.PostProcess(); // Do post-processing (always required)
}

PositionScore=Ref(StochK(15,3),-1);

Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy);

PlotShapes(IIf(Ref(Buy,-1),shapeUpArrow,shapeNone),colorBlue,0,L,-15);
PlotShapes(IIf(Ref(Buy,-1),shapeHollowSquare
,shapeNone),colorBlue,0,BuyPrice,0);
PlotShapes(IIf(Ref(Sell,-1),shapeDownArrow,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Ref(Sell,-1),shapeHollowSquare,shapeNone),colorRed,0,SellPric
e,0);
//---END OF CODE--





RE: [amibroker] Re: pl. code this

2010-07-18 Thread Matthias K.
Why not spend a minute in YOUR education and try to solve your programming
riddle yourself?

 

If there’s specific advice on a specific step in your coding, go ask for it:
Please do! Present your code! There’s plenty of sophisticated long-term
users in here that offer their valuable advice for free if they see “your
piece of the pie”

 

But as long as you don’t want to dig a little deeper into Amibroker coding,
why bother at all? 

 

I’m sure you bought that piece of software because it’ll serve you a
precious service for the time you’re trading / future purpose. So why not
make the effort and understand it in great detail?

Believe me, this path is worth pursuing. Btw:  this “awesome John Carter
Idea” is not going to be as great as you think - trading it mechanically. 

 

Greets from Germany,

 

M

 

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of bharat
Sent: Montag, 19. Juli 2010 04:06
To: amibroker@yahoogroups.com
Subject: [amibroker] Re: pl. code this

 

  

AFL which you have mentioned is available here.Check and tweak.

--- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com , cas
soni soni...@... wrote:

 Hello ,I had given you BBsqueeze .afl  indicator long time ago...use
that..i think it is same as per mt4 indicator..* i dont have that afl have
a nice time. .
 
 --- On Sun, 18/7/10, bharat bharat_parth2...@... wrote:
 
 From: bharat bharat_parth2...@...
 Subject: [amibroker] Re: pl. code this
 To: amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com 
 Date: Sunday, 18 July, 2010, 5:41 PM
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Â 
 
 
 
 
 
 
 
 
 
 Hi
 
 
 
 Found full MT4 code for this.Pl. Code AFL 
 
 
 


===
 
 // This indicator is based on a strategy mentioned in John Carter's book,
Mastering the Trade. The basic idea 
 
 // behind the strategy is that markets tend to move from periods of low
volatility to high volatility and
 
 // visa versa. The strategy aims to capture moves from low to high
volatility. For gauging this he uses two 
 
 // common indicators - Bollinger Bands and Keltner Channels (ok, not so
common!). He also uses the Momentum 
 
 // indicator to provide a trade bias as soon as the Bollinger Bands come
back outside the Keltner Channels.
 
 // 
 
 // The Squeeze_Break indicator combines this into a signal indicator and
has the following components:
 
 // 1. A positive green histogram means that the Bollinger Bands are
outside the Keltner Channels
 
 // and the market is lightly to be trending or volatile. The stronger the
histogram the stronger 
 
 // the directional price move.
 
 // 2. A negative red histogram means that the Bollinger Bands are inside
the Keltner Channels 
 
 // and the market is lightly to be consolidating. The stronger the red
histogram the tighter
 
 // price action is becoming.
 
 // 3. Incorporated into the indicator is a Momentum indicator. According
to the strategy J. Carter
 
 // goes long when the Bollinger Bands break outside the Keltner Bands and
the Momentum indicator 
 
 // is above the zero line. He goes short when the Momentum indicator is
below the zero line on the 
 
 // break.
 
 // 4. I've also added other indicator info in the top left hand corner to
give a broader idea 
 
 // of current market conditions.
 
 // 5. The indicator provides audio alerts when a potential breakout is
occurring. 
 
 // 
 
 // This indicator tends to be better with the larger timeframes.
Personally I don't trade on an alert 
 
 // signal alone. It's just a handy tool for warning me of potential
breakout trades. 
 
 //

===
 
 
 
 #property copyright DesORegan
 
 #property link mailto: oregan_...@...
 
 
 
 
 
 
 
 // 
 
 // indicator properties
 
 // 
 
 #property indicator_separate_window
 
 #property indicator_buffers 3
 
 #property indicator_color1 ForestGreen
 
 #property indicator_color2 Red
 
 #property indicator_color3 Blue
 
 
 
 
 
 // ===
 
 // User Inputs
 
 // ===
 
 extern int Boll_Period=20;
 
 extern double Boll_Dev=2.0;
 
 extern int Keltner_Period=20;
 
 extern double Keltner_Mul=1.5;
 
 extern int Momentum_Period=12;
 
 extern int Back_Bars=1000;
 
 extern bool Alert_On=true;
 
 extern bool On_Screen_Info=true;
 
 
 
 
 
 // =
 
 // Buffer Array Declarations
 
 // =
 
 double Pos_Diff[]; // Pos Histogram
 
 double Neg_Diff[]; // Neg Histogram
 
 double Momentum[]; // Momentum Indicator 
 
 
 
 
 
 // ===
 
 // Internal Array Declarations
 
 // ===
 
 double Squeeze[]; // Used to track which i (index value) is above 
 
 // and below zero line. 0 followed by 1 triggers alert 
 
 
 
 // = 
 
 // 

RE: [amibroker] Hold a trade for a minimum # of bars

2010-07-14 Thread Matthias K.
Hi,

 

This one is from Mr. Janeczko, he put it online as an example, but I cannot
find the link. Replace buy/sell,etc. witch your rules, the rest is pretty
much self-explanatory.

 

Buy = MACD()  0 AND RSI()  30;

Sell = MACD()  0 OR Cross( 70, RSI() );

SetPositionSize(1,spsShares);

// now we would like to ensure that position is NOT

// exited during first MinHoldBars 

 

MinHoldBars = 17; // say don't want to exit for first 17 bars since entry

 

// first filter out buy signals occuring outside testing range

Buy = Buy AND Status(barinrange);

 

BarsInTrade = 0;

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

{

  // if in-trade, then increase bar counter

  if( BarsInTrade  0 ) BarsInTrade ++;

  else

  if( Buy[ i ] ) BarsInTrade = 1; // on buy signal start counting
bars-in-trade

 

  // if we are in trade - remove sells occurring too soon

  if( BarsInTrade  MinHoldBars ) Sell[ i ] = 0;

  else

  if( Sell[ i ] ) BarsInTrade = 0; // on sell reset barsintrade flag

}

printf(barsintrade:\n);

WriteVal(barsintrade);

 

 

 

Greets,

Matthias

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of JEFF F
Sent: Donnerstag, 15. Juli 2010 00:41
To: amibroker@yahoogroups.com
Subject: [amibroker] Hold a trade for a minimum # of bars

 

  

Can anyone tell me how to hold a trade for a minimum # of bars (such as 3)
before checking for a sell signal? 

I have tried settradedelay(0,3,0,0) but when i backtest, the trade still
happens the next day. Same with changing the delay within the settings
button.

Any help is appreciated.

Thanks





RE: [amibroker] FOREX brokers and data feed differences

2010-07-06 Thread Matthias K.
Not sure if it helps, but give it a try:

 

FX is traded 24 hrs, thus the timestamp of your MT broker may be stamped
differently as compared to finam (=Russia) data. Be careful with data
selection in FX anyways, it's an interbank market that is not watched by
authorities, hence is not regulated. Data from one provider may be more
volatile, compared to another. Having too little information about your
project, it's difficult to give you better  advice than this: When
backtesting a FX-System, be sure that the data comes from the broker you
want to trade with!

 

If you're thinking of buying data, you might stumble across their site:
http://disktrading.is99.com/disktrading/

Unfortunately the FX data is very very noisy and I abandoned it for system
development in FX (unless you trade on daily charts). Their futures data is
ok (as in ok, not outstanding), though.

 

Here's another free data source you may wanna play with. 

 

http://www.dukascopy.com/swiss/english/data_feed/csv_data_export/

 

Last but not least: IMHO always give ECN brokers a preference, they're
interested in executing your trades only and don't act as a market maker. IB
is an ECN borker, MB Trading (has MT4) is another one.

 

 

 

From: amibroker@yahoogroups.com [mailto:amibro...@yahoogroups.com] On Behalf
Of BruceD
Sent: Dienstag, 6. Juli 2010 06:59
To: amibroker@yahoogroups.com
Subject: [amibroker] FOREX brokers and data feed differences

 

  

This is my first post on this forum so please point me in the right
direction if I'm doing something wrong.

I'm looking for advice from someone who may have been down this road
allready.

I've been trading FOREX using MQ4 for a few years, but have allways been
frustrated by its inadequate back testing capabilites. I recently found
AmiBroker and Howard Bandy's books. This has been a real quantum leap for me
and I'm anxious to apply some of the methods I've learned. 

Here's the problem: Using AmiQuote to download FOREX history, the data feed
comes from FinAm. Using the backtesting and optimization tools in AmiBroker
I've develped a succesfull trading system, however, I don't have a broker
set up to accept live trades from AmiBroker yet.

As a test, I wrote the same system in the MQ4 system with my existing broker
and ran it live for a while. Its performance was poor. Further research has
shown that difference in performance is due to the fact that the data from
FinAm and that from my MQ4 based broker (IBFX) is very different!

I would like to switch to a FOREX broker that will allow me to do live
trading from AmiBroker, hopefully that uses the same data source as FinAm,
and of course that has reasonable rates. If I read the info on FinAm's
website properly, their small USD 10 fee per trade in addition to a higher
than normal spread is a deal breaker for me.

Has anyone else experienced this issue with FOREX data? Does anyone have a
broker they are doing live FOREX trading with via AmiBroker that they are
happy with? I do a lot of intra-day trades.

Any suggestions would be appreciated. Again, if I'm posting incorrectly or
in the wrong area, please let me know.

Thanks!





[amibroker] Re: How to mix systems

2010-07-06 Thread Matthias


As you can see from my questions/answers, I'm always interested in finding new 
solutions. but quote me if I'm wrong: with your approach you are NOT using ONE 
equity pool.

Say you have 100k$,
with your methodology you would do one of the following:

Assign 50k$ or 50% to System1
Assign 50k$ or 50% to System2

== Backtest and combine equity curves as you said.

Alternativley you might prop up the result in using 100k$ to backtest your 2 
Systems. If you operate on a non-percent-risk model, it might work, but a 
non-percent-risk model ( e.g. fixed number of shares) is not really 
state-of-art.

...just thinking out loud...


--- In amibroker@yahoogroups.com, notanaiqgenius notanaiqgen...@... wrote:

 Hi System Mixers,
 
 I've been following this thread. I see people want to do different things 
 when they say mix systems. If all you want to do is backtest on daily bars 
 with multiple systems, yet be able to test each system by itself first, one 
 simple way might be to obtain each system's equity curve (preferably 
 walk-forward OOS curve), and then export that curve to a CSV file.
 
 Once you have say, 2 or more systems that you want to time / combine, you can 
 then create a new AB database with nothing in it, and then import the equity 
 curves as pseudo/fake symbols using just Date and Close, where the Close is 
 your equity value from that system.
 
 Then you could write one code to rank or time the equity curves.
 
 Sure, that's quite a bit different than controlling and combining all the 
 individual orders of all the systems, but if you want to keep your system's 
 separate and just time their individual equity curves, then this sort of 
 approach might work.
 
 The down side is that you wouldn't be able to see how much risk you are 
 taking on 1 stock. Like, if all systems pile into AAPL Long, that might be 
 pretty bad. Another down side is I could see it being a pain to update going 
 forward.
 
 -Paul
 
 --- In amibroker@yahoogroups.com, Gonzaga gonzagags@ wrote:
 
  Hi. 
  I am lately trying to mix several systems in on meta-system, and I am 
  observing that is not difficult to obtain good CAR's with low Draw Downs.
  For example, system 1 trade against 100 tickers of the NAsdaq-100 and 
  system 2, against the same 100 tickers. Both systems 'compete' for the 
  money.
  This is a 'Meta-system', multi-system and multi-stock.
  
  Well, I see it's not very difficult to obtain profitable systems..
  I see also that a good filter to improve results is to filter every system 
  with a volatility value of the index you are using, for example ATR of NQ, 
  or ATR of SPX. So you trade any system in the best moment for the system.
  You have to filter all your systems, and then, mix them in one meta-system.
  I thing it's not very hard to obtain annualized CARs 30% and DD less than 
  20%.
  BUT, it's hard to programme and backtest. 
  Amibroker backtests very easily many stocks, but to mix several systems is 
  a mess.. difficult and easy to fail..
  Does anybody know a trading platform that creates this kind of meta-system 
  easily? (perhaps trade station?)
  Or a way to mix and backtest 2 or 3 systems easily in Ami?
  
  Thanks
 





RE: [amibroker] Re: How to mix systems

2010-07-06 Thread Matthias K.
Que tal gonzaga?

 

After sending this email, I figured that this might happen: I was answering
to Paul's post. Strange Yahoo, sorry for the confusion. I'm afraid I cannot
help you on your custom backtest proc, yet.

 

Hi System Mixers,
  
  I've been following this thread. I see people want to do different
things when they say mix systems. If all you want to do is backtest on daily
bars with multiple systems, yet be able to test each system by itself first,
one simple way might be to obtain each system's equity curve (preferably
walk-forward OOS curve), and then export that curve to a CSV file.
  
  Once you have say, 2 or more systems that you want to time / combine,
you can then create a new AB database with nothing in it, and then import
the equity curves as pseudo/fake symbols using just Date and Close, where
the Close is your equity value from that system.
  
  Then you could write one code to rank or time the equity curves.
  
  Sure, that's quite a bit different than controlling and combining all
the individual orders of all the systems, but if you want to keep your
system's separate and just time their individual equity curves, then this
sort of approach might work.
  
  The down side is that you wouldn't be able to see how much risk you are
taking on 1 stock. Like, if all systems pile into AAPL Long, that might be
pretty bad. Another down side is I could see it being a pain to update going
forward.
  
  -Paul



Answer:

 

 As you can see from my questions/answers, I'm always interested in finding
new solutions. but quote me if I'm wrong: with your approach you are NOT
using ONE equity pool.
 
 Say you have 100k$,
 with your methodology you would do one of the following:
 
 Assign 50k$ or 50% to System1
 Assign 50k$ or 50% to System2
 
 == Backtest and combine equity curves as you said.
 
 Alternativley you might prop up the result in using 100k$ to backtest
your 2 Systems. If you operate on a non-percent-risk model, it might work,
but a non-percent-risk model ( e.g. fixed number of shares) is not really
state-of-art.
 
 ...just thinking out loud...







[amibroker] Re: How to mix systems

2010-07-02 Thread Matthias
Thanks my Mike for posting the links.

Btw I also contacted support for this issue because if this one proves to be 
feasible, there will be sort of a lot of money at risk AFTER DEMO-ING the 
system. I need to be sure. Many thanks also to Marcin from the Amibroker 
support team that offers sophisticated and fast support. From a theoretical 
point of view, I came to a conclusion, but please do not ask me about the 
practical deatils yet, I am not even sure if this is a reliable concept. 
(Reliable is the keyword in that sentence, I doubt that this concept would be 
reliable when applied to 3 or even 10 systems)

I do NOT require anyone to work out a custom tailored solution for this 
problem, and I am aware of the AT forum and I read up on autotrading in the 
user knowledge base. Yes, I also did study one post referring to static 
variables.

As matter of fact, this is what I figured out so far:

Mike's post does not work in AT/RT environment. You need to write one MASTER 
AFL that references/includes all the individual system logics. To avoid 
overlapping or referencing buy1 to sell2, or sell3, etc. one needs to use 
STATIC VARIABLES.

== REAL TIME TRADING multiple systems is vastly different from BACKTESTING 
multiple systems.

STATIC VARABLES is the concept that I did not understand initially but I read 
up on it again in greater detail. Another problem with my thought process was 
that I mixed up BACKTESTING MULTIPLE SYSTEMS and REAL TIME TRADING SYSTEMS.

== Mike's Custom Backtest Procedure works on BACKTESTS: NOT AT
== Keith's post theoretically suggests the right way for REAL TIME TRADING, 
NOT BACKTESTING: this approach has been offered from Amibroker support, too 
(I'll explain later on)

What to do:

REMEMBER: MULTIPLE SYSTEMS ON THE VERY SAME UNDERLYING

You process orders internally to an, let me call it position pool:
bar1:
SYSTEM A: +2 contracts (2 contracts long)
SYSTEMB: -1 contract (1 contract short)

total: +1 contract.
place order (LONG) for 1 contract.


Bar2:
SYSTEM A: no signal
SYSTEM B: -2 contract
place order (SELL) -2 contract

overall = -1contract

== Amibroker is capable of handling this problem, so to say transmits only the 
netted/ summed up positions to IB with the restriction of being net flat:

[-1 contract ] + [+1 contract] == to Amibroker it means flat.

== To me it means what's written there: +1 and -1

I am gonna stop at this point. Thank you all for your kind suggestions and 
help. Always good to get multiple inputs. This piece of code is gonna be very 
very very long.

Have a nice weekend! Greets from Germany, Farewell for me.

Matthias




--- In amibroker@yahoogroups.com, Mike sfclimb...@... wrote:

 What I described was aimed at backtesting multiple systems to emulate how you 
 trade in real life (i.e. generate statistics for how you would have traded, 
 as opposed to what you should trade next).
 
 I suspect that the approach that I outlined would not help generate trades 
 for you in real time since by definition the backtest acts on bars that have 
 already closed.
 
 I don't auto trade, so I'll leave that advice for others to offer. However, I 
 can point you to some links that can get you started.
 
 Your first point of research should probably be the User's Knowledge Base. 
 Herman and Al have written extensively there:
 
 http://www.amibroker.org/userkb/
 
 Next, there is a dedicated Yahoo group for AmiBroker auto trading: 
 
 http://finance.groups.yahoo.com/group/AmiBroker-at/?yguid=83897329
 
 A member of that group, Barry, has posted a skeleton auto trading system to 
 the AFL Library which may be useful:
 
 http://www.amibroker.com/members/library/detail.php?id=1225
 
 
 Mike
 
 --- In amibroker@yahoogroups.com, Matthias meridian202@ wrote:
 
  Keith and Mike,
  
  thank you very much for your helpful postings. Looks like I'll have a long 
  weekend :).
  
  Obviously I need to absorb and test what you've just said in great detail 
  which will require time. I shall keep you posted. Just wondering if this is 
  such an akward out-of-the-world problem. Things start to get complex here 
  real quick (for me at least) and whatever approach I take, it seems to be 
  error-prone if not done/checked ultra-carefully. Maybe this one could be 
  implemented a little easier in future versions of Ami so that one could 
  spend more time on system development or portfolio composition rather than 
  spending hours n days to tailor simple AFL's into 1 complex 
  multi-AFL-combined-and-custom-backtest-proc-afl
  
  Regarding Keith's post e):
  
  //
   I don't know if AB can properly handle long and short positions 
  simultaneously in the same stock or contract.  That will require a simple 
  experiment on your part. If AB can't, then simply export your symbol of 
  choice, import into a spread sheet or text editor, change the symbol to 
  something unique like symbol_SO, and import back into your data base

[amibroker] Re: How to mix systems

2010-07-01 Thread Matthias











Hello,

I am having trouble understanding the same issue. If anyone here has a solution 
I'd like to read up on it as well. Angelo, I have read literally every 
discussion in this forum regarding this topic and I understand why your 
reffering to TJ, and please: Yes, I did read the user manual and yes, I did 
read custom backtester procedure. I believe that I am not the only one who's 
facing this. Help appreciated. I'd like to post 3 sample strategies for better 
understanding (which won't work, btw).

BASE-TIME: 5min; [ONLY 3 Strategies]

Setpositionsize(number, spsshares) // number varies depending on which strategy 
gets the signal
Setoption(maxopenpositions,3) //i.e. every strategy can open 1 position at a 
time which is not reflected in this command


/ MA-Crossover  //

Ema1=ema(c,10);
Ema2=ema(c,20);

Buy1=cross(ema1,ema2);
Sell1=cross(ema2,ema1);
Short1=sell1;
Cover1=buy1;

/// Countertrend/

BBupperiod1= 20; 
BBlowperiod1= 20; 
BBupSTD1= 2;
BBlowSTD1= 2;
BBtop1=  BBandTop(C,BBupperiod1,BBupSTD1);   
BBbot1=  BBandBot(C,BBlowperiod1,BBlowSTD1);  

MA1= ma(C,20);

Buy2= Cbbandbot1; 
Sell2= cma1;
Short2= Cbbandtop1;
Cover2= Cma1;

Buy2= exrem(Buy2,sell2);
Sell2= exrem(sell2, buy2);
Short2= exrem(short2,cover2);
Cover2= exrem(cover2,short2);

/// HH LL //

TimeFrameSet(inhourly);

period1high=20;
period1low=20;

nhigh=HHV(H,period1high);
nlow=LLV(L,period1low);

TimeFrameRestore();

Buy3= timeframeexpand(ndayhigh,inhourly)  timeframeexpand(ref(ndayhigh,-1), 
inhourly);
Sell3= timeframeexpand(ndaylow,inhourly)  timeframeexpand(ref(ndaylow,-1), 
inhourly);
Short3=sell3;
Cover3=buy3;


REALIME TRADING:

What do I need to do is to put these 3 into one AFL for real-time trading - 
that's what people were saying. How do I arrange the code?

I do not trade a lot of underlyings, but say, this one needs to be run on the 
FDAX(German bluechip future) and on the FDAX only, allowing shorts and longs at 
the same time.
I have read up on the

if ( name==)  idea.

but I want to realtime trade this on ONE underlying only (Trying to express: I 
cannot change the name of the underlying in realtime trading, so that amibroker 
would think it's 3 differnt tickers, even though it's only one)

Another suggestion was something with static variables, but I didn't grasp the 
concept. 

Another suggestion was from Keith Mccombs, suggestion one MASTER-AFL, to 
control the other afl's.

#include afl1
#include afl2


=== how do I match buy1 and sell2?

BACKTESTING

I believe that the issue above differs from the actual backtest-logic and has 
been vastly mixed causing a lot of confusion. The way I currently see it is, in 
order to get a proper backtest of multiple systems, one would either need 
custom backtest proc or --- in this (my case above) case with only one 
underlying traded --- name the same underlying differently e.g. FDAX1 for 
system #1 FDAX2 for system #2. Not so elegant, but if it works I'm fine with it.



MONEY MANAGEMENT AND PORTFOLIO COMPOSITION

Obviously, if you have figured out what and how much to trade, this one is 
already resolved. But maybe sometimes one would like to try different things or 
at least check different inputs. Such as:

One Equity Pool
Several equity pools,
manipulate position size if one system is performing poorly,
have a system ranking funtion (which system to trade now - based on equity 
curve, e.g.)
do some sort of modern portfolio theory.


I don't want to go in the details on MONEY MANAGEMENT AND PORTFOLIO 
COMPOSITION and for now I'd be delighted if someone could show me how to match 
my buy/sell signals for realtime trading. One software which I know of and is 
capable of adressing all these problems easier is rina portfolio maestro.

http://www.portfoliomaestro.com/

I haven't tried it and I'm also not planning on doing so (10k$ per year), but I 
wanted to understand what's possible.



Greetings,

M
 

--- In amibroker@yahoogroups.com, Jeff jeffro...@... wrote:

 In any case you'll have to decide on the logic to decide on allocation. After 
 you do that,   You could make the meta system a linear combination of the 
 two.  Create multiple randoms runs of each and assign a static variable, to 
 the random equity curves.  That way you could do a Monte Carlo analysis with 
 both sets together and different allocations.  But then again I would I 
 strongly suggest researxhing and understanding the characters of the 
 tendencies you are exploiting instead of smashing them together blindly.   
 
 --- In amibroker@yahoogroups.com, Gonzaga gonzagags@ wrote:
 
  Hi. 
  I am lately trying to mix several systems in on meta-system, and I am 
  observing that is not difficult to obtain good CAR's with low Draw Downs.
  For example, system 1 trade against 100 tickers of the NAsdaq-100 and 
  

[amibroker] Re: How to mix systems

2010-07-01 Thread Matthias
Sorry for the typo in the Backtesting-Paragraph:

Should read:

match buy1 and sell1 (NOT: buy1 and sell2)



--- In amibroker@yahoogroups.com, Matthias meridian...@... wrote:

 
 
 
 
 
 
 
 
 
 
 
 Hello,
 
 I am having trouble understanding the same issue. If anyone here has a 
 solution I'd like to read up on it as well. Angelo, I have read literally 
 every discussion in this forum regarding this topic and I understand why your 
 reffering to TJ, and please: Yes, I did read the user manual and yes, I did 
 read custom backtester procedure. I believe that I am not the only one who's 
 facing this. Help appreciated. I'd like to post 3 sample strategies for 
 better understanding (which won't work, btw).
 
 BASE-TIME: 5min; [ONLY 3 Strategies]
 
 Setpositionsize(number, spsshares) // number varies depending on which 
 strategy gets the signal
 Setoption(maxopenpositions,3) //i.e. every strategy can open 1 position at 
 a time which is not reflected in this command
 
 
 / MA-Crossover//
 
 Ema1=ema(c,10);
 Ema2=ema(c,20);
 
 Buy1=cross(ema1,ema2);
 Sell1=cross(ema2,ema1);
 Short1=sell1;
 Cover1=buy1;
 
 /// Countertrend  /
 
 BBupperiod1= 20;   
 BBlowperiod1= 20; 
 BBupSTD1= 2;  
 BBlowSTD1= 2;  
 BBtop1=  BBandTop(C,BBupperiod1,BBupSTD1); 
 BBbot1=  BBandBot(C,BBlowperiod1,BBlowSTD1);  
 
 MA1= ma(C,20);
 
 Buy2= Cbbandbot1; 
 Sell2= cma1;
 Short2= Cbbandtop1;
 Cover2= Cma1;
   
 Buy2= exrem(Buy2,sell2);
 Sell2= exrem(sell2, buy2);
 Short2= exrem(short2,cover2);
 Cover2= exrem(cover2,short2);
 
 /// HH LL //
 
 TimeFrameSet(inhourly);
 
 period1high=20;
 period1low=20;
 
 nhigh=HHV(H,period1high);
 nlow=LLV(L,period1low);
 
 TimeFrameRestore();
 
 Buy3= timeframeexpand(ndayhigh,inhourly)  timeframeexpand(ref(ndayhigh,-1), 
 inhourly);
 Sell3= timeframeexpand(ndaylow,inhourly)  timeframeexpand(ref(ndaylow,-1), 
 inhourly);
 Short3=sell3;
 Cover3=buy3;
 
 
 REALIME TRADING:
 
 What do I need to do is to put these 3 into one AFL for real-time trading - 
 that's what people were saying. How do I arrange the code?
 
 I do not trade a lot of underlyings, but say, this one needs to be run on the 
 FDAX(German bluechip future) and on the FDAX only, allowing shorts and longs 
 at the same time.
 I have read up on the
 
 if ( name==)  idea.
 
 but I want to realtime trade this on ONE underlying only (Trying to express: 
 I cannot change the name of the underlying in realtime trading, so that 
 amibroker would think it's 3 differnt tickers, even though it's only one)
 
 Another suggestion was something with static variables, but I didn't grasp 
 the concept. 
 
 Another suggestion was from Keith Mccombs, suggestion one MASTER-AFL, to 
 control the other afl's.
 
 #include afl1
 #include afl2
 
 
 === how do I match buy1 and sell2?
 
 BACKTESTING
 
 I believe that the issue above differs from the actual backtest-logic and has 
 been vastly mixed causing a lot of confusion. The way I currently see it is, 
 in order to get a proper backtest of multiple systems, one would either need 
 custom backtest proc or --- in this (my case above) case with only one 
 underlying traded --- name the same underlying differently e.g. FDAX1 for 
 system #1 FDAX2 for system #2. Not so elegant, but if it works I'm fine with 
 it.
 
 
 
 MONEY MANAGEMENT AND PORTFOLIO COMPOSITION
 
 Obviously, if you have figured out what and how much to trade, this one is 
 already resolved. But maybe sometimes one would like to try different things 
 or at least check different inputs. Such as:
 
 One Equity Pool
 Several equity pools,
 manipulate position size if one system is performing poorly,
 have a system ranking funtion (which system to trade now - based on equity 
 curve, e.g.)
 do some sort of modern portfolio theory.
 
 
 I don't want to go in the details on MONEY MANAGEMENT AND PORTFOLIO 
 COMPOSITION and for now I'd be delighted if someone could show me how to 
 match my buy/sell signals for realtime trading. One software which I know of 
 and is capable of adressing all these problems easier is rina portfolio 
 maestro.
 
 http://www.portfoliomaestro.com/
 
 I haven't tried it and I'm also not planning on doing so (10k$ per year), but 
 I wanted to understand what's possible.
 
 
 
 Greetings,
 
 M
  
 
 --- In amibroker@yahoogroups.com, Jeff jeffro861@ wrote:
 
  In any case you'll have to decide on the logic to decide on allocation. 
  After you do that,   You could make the meta system a linear combination of 
  the two.  Create multiple randoms runs of each and assign a static 
  variable, to the random equity curves.  That way you could do a Monte Carlo 
  analysis with both sets together and different allocations.  But then again 
  I would I strongly suggest researxhing and understanding the characters of 
  the tendencies you are exploiting

[amibroker] Re: How to mix systems

2010-07-01 Thread Matthias
































Thanks Keith for joining this discussing. I don't quite know who you're trying 
to adress with your question/suggestion.

Assuming you refer to my previous post:

1. Put those three Systems in one afl as you would when autotrading: Each 
System has its BUY and SELL and SHORT and COVER: I want system1 to refer only 
and only to its predetermined buy1,sell1,short1,cover1 rules

2. Each System uses ATR positionsizing, obviously not the same number of 
contracts traded due to different timeframes and different system logic

3. FDAX is a futures contract: The systems are intended to share the same 
equity pool [to be precise: closed equity]

4. All Systems trade this ONE underlying only

5. Each System is allowed to open ONE position at a time, not matter what 
positions of the remaining systems are open or closed

6. As stated in the text below: Same time longs and shorts of different systems 
are allowed: E.g. system1(long), system2(short), system3(no-pos)

7. Each system has its own predetermined exits, no matter what the other 
systems do [edit: in order to NOT complicate things further, I skipped 
Applystop in the system logic of my example in the previous post]

8. Backtest each system individually is no prob, together with FDAX1,FDAX2 
(faking different underlyings to amibroker)... no prob either



So: The way I understand it currently is: For Ami to autotrade, I need to write 
the logic of the 3 systems into 1 AFL. Taking all the above mentioned points 
into consideration: How does one do that?



In that sense you are right: Possibly Mixing Systems as a topic is a bit weak 
in determining what each user wants. My idea was to breakdown this whole topic 
in 3 main areas:

*Realtime-Trading environment and relating issues
*Backtesting multiple Systems simultaneously in general
*Broken down further in various portfolio and moneymangement techniques: which 
MM and Portfoilio Management is best for my Trading system basket, individual 
system ranking (with equity curve, don't know a better metric for the system 
than equity curve), or also the other topics involved: Walk-Forward Efficiency 
Ratio (for each individual system), Modern Portfolio Design (here referring to: 
Multiple Systems logics on different underlying to produce smoothest, 
risk-adjusted PORTFOLIO equity)

Hope I made myself clearer, but you're right the topic is huge and some of it 
has been discussed some time ago. The thing that gives me a headache is that I 
couldn't find a practicle example that would gather together the conclusions 
out of the discussion. The idea to break this topic down into the 3 parts are a 
suggestion to make things easier, I'm not sure if it's the best solution due to 
overlapping. But come on, we shot a rocket to the moon, this little there needs 
to be possible.

Thanks,

M 

--- In amibroker@yahoogroups.com, Keith McCombs kmcco...@... wrote:

 I've read a number of posts on the thread.  And it seems to me that not 
 everyone has the same meaning in mind when they are talking about a 
 'MIX' system.
 
 What do you mean by a mix system?  I assume that two or more systems are 
 supposed to share SOMETHING.  Is that SOMETHING,
 1.  The same equities?  If so, what do you want to happen if two or more 
 systems want to go in different directions, perhaps one holds while 
 another sells, or even another shorts?  Once you have answered these 
 questions, you might find that sigScaleIn and sigScaleOut will help you out.
 
 2.  Available cash?  If so, to what extent?  If you know, then maybe use 
 setPositionSize() and/or PositionScale can help you.
 
 3.  Risk and rewards, but keeping money from profits and losses 
 separate?  If so, try backtesting separately.  Then save ~~~Equity 
 results with different names and add them in AB, with buy and hold for each.
 
 4.  Or, maybe something else?
 
 -- Keith
 
 On 7/1/2010 17:29, Matthias wrote:
 
  Sorry for the typo in the Backtesting-Paragraph:
 
  Should read:
 
  match buy1 and sell1 (NOT: buy1 and sell2)
 
  --- In amibroker@yahoogroups.com mailto:amibroker%40yahoogroups.com, 
  Matthias meridian202@ wrote:
  
  
  
  
  
  
  
  
  
  
  
  
   Hello,
  
   I am having trouble understanding the same issue. If anyone here has 
  a solution I'd like to read up on it as well. Angelo, I have read 
  literally every discussion in this forum regarding this topic and I 
  understand why your reffering to TJ, and please: Yes, I did read the 
  user manual and yes, I did read custom backtester procedure. I believe 
  that I am not the only one who's facing this. Help appreciated. I'd 
  like to post 3 sample strategies for better understanding (which won't 
  work, btw).
  
   BASE-TIME: 5min; [ONLY 3 Strategies]
  
   Setpositionsize(number, spsshares) // number varies depending on 
  which strategy gets the signal
   Setoption(maxopenpositions,3) //i.e. every strategy can open 1 
  position at a time which is not reflected in this command

[amibroker] Re: How to mix systems

2010-07-01 Thread Matthias









Keith and Mike,

thank you very much for your helpful postings. Looks like I'll have a long 
weekend :).

Obviously I need to absorb and test what you've just said in great detail which 
will require time. I shall keep you posted. Just wondering if this is such an 
akward out-of-the-world problem. Things start to get complex here real quick 
(for me at least) and whatever approach I take, it seems to be error-prone if 
not done/checked ultra-carefully. Maybe this one could be implemented a little 
easier in future versions of Ami so that one could spend more time on system 
development or portfolio composition rather than spending hours n days to 
tailor simple AFL's into 1 complex 
multi-AFL-combined-and-custom-backtest-proc-afl

Regarding Keith's post e):

//
 I don't know if AB can properly handle long and short positions simultaneously 
in the same stock or contract.  That will require a simple experiment on your 
part. If AB can't, then simply export your symbol of choice, import into a 
spread sheet or text editor, change the symbol to something unique like 
symbol_SO, and import back into your data base.  Now you have two separate 
symbols, which we know AB can handle properly.

///

Just by reading it, I figured that one would require an external source, such 
as Excel. Problem here is that this is supposed to work in RT environment doing 
autotrading, anyways I'll look into it.



Regarding Mike's post:

///
I haven't actually tried any of the above, and do not know how well
it would translate into auto trading 
///

Sounds like this is something extraordinary, but are there so little user 
asking about this multiple-system concept? Look, I don't have an account to 
autotrade yet, but if I figured out a way on how to do this, this would be run 
in AA window, backtesting the system, so to say - run that piece of code 
every xx minutes, is that correct? I remember somebody from Amibroker support 
told me to program it like a scan and think of autotrading like I would just 
scan for signals. Not sure if I understand the concept, but does scan include 
custom backtest proc?

I'll see what goes, but out curiosity: just wondering if the execution speed of 
this code would be proefficient.


Thanks again.





[amibroker] Re: inconsistent EOD data

2010-04-13 Thread Matthias


There is literally NO workaround to the problem you just described. I agree, 
due to different timestamps of data, especially with finam (Russia) these 
differences can be explained. But this issue becomes more and more 
unpredictable the shorter the time frame you are trading, i.e. one minuter or 
one day. 10 pips on a daily move just don't mean that much as on a 1 minute 
chart especially on news releases or at important support/resistance levels. 
But it's already been mentioned: go for futures at the CME, this market is 
regulated whereas the brokers simply are not.
Or to put it in different words: FX is an unregulated market where banks can 
make up the price they want within certain limits (especially at an 
accumulation of stops).

Something more to worry:

http://www.forexfactory.com/showthread.php?t=70582

Well that's kinda nasty, but it's true when dealing forex.


In his book Beat the Forex Dealer by Augustin Silvani, he even explains that 
a well known FX-Broker, called FXC(guess the last letter) state that these 
folks are big on advertising no-dealing-desk-execution whereas no dealing 
desk only means that the desk has been replaced with a sophisticated algorhitm 
that's run by a computer.

Suggestion: Trade breakouts in the direction of the breakout on shorter time 
frame or benefit from the longer term trend.

PS Finam uses indicative data, thus it's sort of a extra-multi-bank 
composition. If you use other brokers, they might get their quotes from a more 
limited number of source banks. In FX: the only quote that counts is the 
quote of your broker, so be wary when buying data from different vendors other 
than the broker you are dealing with.

Regards,

M.

--- In amibroker@yahoogroups.com, rutle1 rut...@... wrote:

 Consider that we went to Daylight Savings Time here in the EST, and Russian 
 time (finam.com) didn't change yet? So maybe the quotes are 1 hour off until 
 their timezone changes?
 
 --- In amibroker@yahoogroups.com, Bob Pitatzidis bobz2335@ wrote:
 
  Hello all
  
  I just checked the End of Day price for forex-EURUSD in 3 different 
  software. They all report different prices:
  
  April 8th:
  VTTrader2: 1,34929
  Metarader5: 1,34984
  Amibroker (from finam.com): 1,3626
  
  
  April 9th:
  VTTrader2: 1,33595
  Metarader5: 1,33572
  Amibroker (from finam.com): 1,33480
  
  I thought that it could be some hour difference, ie GMT vs EST or something 
  like this. BUT April 9th is end of day AND end of the week. They should all 
  report the same price.
  
  Any ideas? 
  
  What site/source can I check for reliable price?
  
  Thanks
  Bob
  
  
  __ Information from ESET Smart Security, version of virus signature 
  database 5018 (20100411) __
  
  The message was checked by ESET Smart Security.
  
  http://www.eset.com
 





[amibroker] Re: Different Applystops for long and short positions possible?

2010-04-07 Thread Matthias

Hi,



I use this one:

buypos=Flip(Buy,Sell);

Shortpos=Flip(Short,Cover);

SLbuy=Optimize(SLbuy,0.5,0.3,0.7,0.05); If you wanna optimize your
stops and profit targets

SLshort=Optimize(SLshort,0.5,0.3,0.7,0.05);

TPbuy=Optimize(TPbuy,1,0.9,1.2,0.05);

TPshort=Optimize(TPshort,1,0.9,1.2,0.05);

SL=IIf(Buypos,SLbuy,IIf(Shortpos,slshort,0));

TP=IIf(Buypos,TPbuy,IIf(Shortpos,tpshort,0));

ApplyStop(stopTypeLoss,stopModePercent,SL);

ApplyStop(stopTypeProfit,stopModePercent,TP);



Sorry for the strange line breaks...

Cheers,

Matthias








--- In amibroker@yahoogroups.com, Markus Witzler funny...@... wrote:

 Hello,

 I want to specify different appystop conditions for long and short
posisions.

 How does AB recognize which one is for which trade?

 Thanks

 Markus



 __ Information from ESET Smart Security, version of virus
signature database 4668 (20091207) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





[amibroker] Re:

2010-02-18 Thread Matthias Kuschel
Hi,

Mike, thanks for helping me out on this. Your code was completely right, I made 
a mistake counting the crossovers, I tried it with other symbols. I appreciated 
your help, thank you very much again, even though my questions were 
starter-questions.


Matthias


  

[amibroker] Re: Could someone comment on how this loop is executed (Basic)

2010-02-18 Thread Matthias


--- In amibroker@yahoogroups.com, Mike sfclimb...@... wrote:

 Hi,
 Nothing wrong with wanting to understand the mechanics. Before getting
 into that, however, I did not understand your comment
 it starts to count wrong(should count to 3, but counts to 2 only
 considering the 1st triple of crossovers, probably due to initializing
 the EMA200) 
 What exactly do you mean by that? Can you give a specific example citing
 a specific symbol over a specific date range and indicate what you
 expected to see vs. what you are seeing?
 Looking at your original post;- Your first attempt should not be using
 AND. Two separate statements separated by ';' is the correct way to go,
 as you had done in the second attempt.
 - In your second attempt, you are using the wrong condition for
 incrementing Counter. You should be checking for true values (i.e. non
 zero).
 Here is a corrected version of your code. I believe that it will give
 you what you want, and, in my tests anyway, line up exactly with the non
 looping version that I sent you originally.
 /* Option 1
 EMA1 = EMA( C, 10 );
 EMA2 = EMA( C, 200 );
 Plot( EMA1, EMA10, colorRed, styleLine );
 Plot( EMA2, EMA20, colorBlue, styleLine );
 
 Buycross[0] = 0;
 exit[0] = 0;
 
 threshold = 3;
 multiplier = 1;
 
 Buycross = Cross( EMA1, EMA2 );
 Counter = Cum( Buycross );
 
 // start loop
 
 for ( i = 0; i  BarCount;i++ )
 {
  if ( Counter[i] == threshold*multiplier )
  {
  multiplier++;
  exit[i] = 1; // separate statements, not AND!
  }
 }
 
 printf( buycross:\n );
 
 WriteVal( Buycross, 1 );
 printf( counter:\n );
 WriteVal( Counter, 1 );
 printf( multiplier:\n );
 WriteVal( multiplier, 1 );
 printf( exit:\n );
 WriteVal( exit, 1 );
 */
 
 
 /* Option 2
 EMA1 = EMA( C, 10 );
 EMA2 = EMA( C, 200 );
 Plot( EMA1, EMA10, colorRed, styleLine );
 Plot( EMA2, EMA20, colorBlue, styleLine );
 
 Buycross[0] = 0;
 exit[0] = 0;
 COUNTER = 0;
 threshold = 3;
 multiplier = 1;
 
 Buycross = Cross( EMA1, EMA2 );
 
 // start loop
 
 for ( i = 0; i  BarCount;i++ )
 {
  if ( buycross[i] != 0 )   // Check for NOT zero!
  {
  counter++;
  }
 
  if ( Counter == threshold*multiplier )
  {
  multiplier++;
  exit[i] = 1;
  }
 }
 
 printf( buycross:\n );
 
 WriteVal( Buycross, 1 );
 printf( counter:\n );
 WriteVal( Counter, 1 );
 printf( multiplier:\n );
 WriteVal( multiplier, 1 );
 printf( exit:\n );
 WriteVal( exit, 1 );
 */
 Mike
 --- In amibroker@yahoogroups.com, Matthias m.kuschel31@ wrote:
 
 
  Hello,
 
  Thanks to all for the prompt reply. (I just figured out how to format
  this, my 1st post looked a little strange).
 
  EMA1 = EMA(C, 10);
 
  EMA2 = EMA(C, 200);
 
  Buycross = Cross(EMA1, EMA2);
 
  Counter = Cum(Buycross);
 
  Triples = Cross(Counter % 3 == 0, 0);
 
  Plot(EMA1,EMA10, colorRed,styleLine);
 
  Plot(EMA2,EMA20,colorBlue,styleLine);
 
  Plot(Triples, Triples, colorGreen, styleOwnScale | styleHistogram);
 
  This code works absolutely fine, many thanks, only problem here: it
  starts to count wrong(should count to 3, but counts to 2 only
  considering the 1st triplele of crossovers, probably due to
 intializing
  the EMA200) any suggestions? But I need you to understand where I am
  coming from:
 
  Obviously you are much more experienced in writing afl than me and I
 get
  Mike's basic concept of avoiding loops for proefficient coding and the
  EMA-plot-labeling was not correct.
 
  You have to understand that I am trying to realize/code my ideas and
 the
  2nd code is where I started off and probably would start off again, be
  it good or bad programming. I do have your solution to my problem now,
  but I still don't understand why my concept does not do the job. Of
  course I did read the articles on How AFL works, this was were I
  started and also got a hand on the barcount funtion which I thought
 was
  the problem (not counting the whole OHLC-array due to faster
 processing
  speed). I also asked my brother on this simple one, who is used to
  programming C. As AFL is C-based I would have assumed this code
 should
  work. Please help me to understand what went wrong / is wrong in my
  logic here, I consider understanding this basic concept to be very
  important for future purpose.
 
  Thanks in advance,
 
  Matthias
 

Hi,
 
Mike, thanks for helping me out on this. Your code was completely right, I made 
a mistake counting the crossovers, I tried it with other symbols. I appreciated 
your help, thank you very much again, even though my questions were 
starter-questions .
 
 
Matthias




[amibroker] Re: Could someone comment on how this loop is executed (Basic)

2010-02-17 Thread Matthias

Hello,

Thanks to all for the prompt reply. (I just figured out how to format
this, my 1st post looked a little strange).

EMA1 = EMA(C, 10);

EMA2 = EMA(C, 200);

Buycross = Cross(EMA1, EMA2);

Counter = Cum(Buycross);

Triples = Cross(Counter % 3 == 0, 0);

Plot(EMA1,EMA10, colorRed,styleLine);

Plot(EMA2,EMA20,colorBlue,styleLine);

Plot(Triples, Triples, colorGreen, styleOwnScale | styleHistogram);

This code works absolutely fine, many thanks, only problem here: it
starts to count wrong(should count to 3, but counts to 2 only
considering the 1st triplele of crossovers, probably due to intializing
the EMA200) any suggestions? But I need you to understand where I am
coming from:

Obviously you are much more experienced in writing afl than me and I get
Mike's basic concept of avoiding loops for proefficient coding and the
EMA-plot-labeling was not correct.

You have to understand that I am trying to realize/code my ideas and the
2nd code is where I started off and probably would start off again, be
it good or bad programming. I do have your solution to my problem now,
but I still don't understand why my concept does not do the job. Of
course I did read the articles on How AFL works, this was were I
started and also got a hand on the barcount funtion which I thought was
the problem (not counting the whole OHLC-array due to faster processing
speed). I also asked my brother on this simple one, who is used to
programming C. As AFL is C-based I would have assumed this code should
work. Please help me to understand what went wrong / is wrong in my
logic here, I consider understanding this basic concept to be very
important for future purpose.

Thanks in advance,

Matthias