Easy Language question -position sizing

Discussion in 'Strategy Building' started by mercurial, Jul 25, 2003.

  1. I thought I'd post here just in case anyone else is attempting something similar.

    I'm trying to base my position size on the equity curve.
    When equity is at a new high I want take a standard (4 contracts for example) position and while in a drawdown I would like to take 1/2 the standard position. I define drawdown as anytime that the current equity is less than the highest equity for the last 4 trades.

    Here is what I tried:

    start$(50000), riskPCT(1.5),riskPCT2(1);

    vars: equity(0), risk$ (0),risk$2(0), risk1(0), risk2(0), NC(0), EquityLow(0);

    Equity = start$+ NetProfit;
    risk1=riskPCT *.01;
    risk2= riskPCT2 *.01;

    risk$ = Equity*risk1*.005;{risks 200 per contract)
    risk$2= Equity*risk1*.005;

    NC = risk$ ;
    if equity [0]<highest( equity, dayz)[0] then
    NC = risk$2 ;

    buy("buy") nc contracts next bar at open;

    The problem is I could have loss and unless the trade takes place within 4 bars I'm not technically in a drawdown according to my rules.

    Any Ideas how I could track the highest equity of the last four trades rather than the equity level for the last four bars?
  2. Funster


    now you've entered a complicated world!

    you have a catch 22 right? if you vary your contracts the equity curve you get is not the one you want to measure as a control.

    Well the answer is a "pseudo" system. this can be put in the same code or called as a separate function. I prefer the former.

    You basically need to code your entire system into variables so that your program keeps a running total of what it would have traded. you can then reference the final variable this spews out that your real trading signals can take as a filter.

    doesn't sound too bad, right? Well it is here you realize just how much work easylanguage does for you normally. For example you are going to have to code exactly how tradestation handles a stop order, limit order etc etc. How does it round up/down fractional prices (by the way there is a bug here for extreme nuumbers so you will never get it exactly right - this will save you a LOT of heartache).

    Also remember that EL processes each bar at the CLOSE of the bar. So if you have e.g. a stop order for the next bar you need to process that stop order in the pseudo system the bar it was filled (i.e. one bar later).

    Be aware this is no mean feat. It will take you 5-10 times longer to create such a "pseudo" system than your whole original one. And you will find bugs in it for weeks after (at least I did!).