Archive for December, 2008|Monthly archive page

I am my worst enemy!

I understand more and more why psychology is a recurring topic in trading.  Since I have been trading I keep discovering (or maybe I should say rediscovering) some old personal demons.  The only difference is that in this pure meritocracy that is trading, those demons tend to have a direct and unquestionable impact on my bottom line.   There are no excuses here, no fingerpointing, no talking my way out of this one.  The spotlight is on me.

Let’s take documentation for instance.  Here my requirements are not even that demanding.  All I need to do is:

  • select the appropriate setup name on the Ninja Trader SuperDome before I take the trade;
  • document each trade on the chart (mark the entry bar, the exit bar, the setup that was used, the results, and a note on lessons learned) and;
  • mark the trade PASS/FAIL depending on whether or not it was taken according to the documented rules.

Well for some unknown reason I still struggle in doing these simple steps for every trade that I take.  For instance I will mark some trades on the chart but not all trades.  I will forget to select the setup name on NT, or I will simply skip the PASS/FAIL grading altogether.  Other days I will do all this perfectly.  Why is that?  Is it because I am inherently undisciplined, is it because taking the time to do this may make me miss the  next big trade, all the above?  I just don’t know and it drives me crazy.

Another wild thing has to do with live trading (vs. simulated trading).  When I was doing pure simulated trading I was convinced that switching to live trading would make me more cautious, more conservative.  I thought that some of those bad habits were due to the fact that I was simply playing with fake money.  So a couple of days ago I took some live trades for the first time and something crazy happened.  I was like a gambler.  I was even less disciplined with real money on the line than with fake money.  I was jumping on trades, I wasn’t even taking the time to assess risk/reward, all the rules were throw out the window.  I saw myself clicking on the buttons but I couldn’t believe it was me doing it.  

These are just a few examples but they concern me.  I need to get a handle on discipline.  I need to understand why this is happening and what I can do to fix it.  I cannot afford these types of mistakes.

FX bot still doing well

I fine tuned the FX bot with a different stop loss and profit target strategy.  In this new version the stop loss is no longer set to a default of 100 pips.  Instead it becomes a measured stop, calculated based on the lowest low (for longs) of the oversold excursion that can eventually lead to the buy signal.  Vice versa, for shorts, the stop is measured as the highest high of the overbought condition that can eventually lead to a sell signal.  However I will cap the stop loss at 100 pips, so in fact the stop loss will be equal to either the measured stop or 100 pips, whichever is lowest.  As this strategy uses a 1:1 risk reward ratio, the profit target is always equal to the stop loss.  Lastly I have included the option of exiting all trades at the close of the session.

This strategy has been doing well on the carry trade pairs and more specifically on the GBPJPY and to a lesser extent on the EURJPY.   Over the last 20 trading days, the bot took 24 trades on the GBPJPY with a 62.5% profitability and netted about $6,700 in profits on a single standard lot.  Those like me with a weak stomach will appreciate the fac that this bot had at most 2 consecutive losing trades but provided as much as 6 consecutive winning trades.

Low-tech solution for evaluating risk & reward

A recent email conversation that I had with Mike from Frankfurt (evidence that there is at least one person other than me reading this blog) about risks and rewards led me to this post.  For once this will not be a new indicator or even a new piece of code but instead I will simply show you how I use three simple horizontal lines on my trading charts to evaluate risk and reward. 

But first I have to explain that I use the ES 576-tick chart as my primary trading chart.  This chart is used to identify the setups, evaluate the bias of the market, and identify potential profit targets.  On the other hand, my 144-tick chart is used to pinpoint entries, identify potential stop loss levels, and evaluate the risk/reward ratio of the trade.  So most of this work is done on the 144-tick chart.  the 576 is only used for profit targets. 

The screen shot below shows three dotted horizontal lines on the 144-tick chart.  The red dotted line is my stop loss.  I typically set my stop loss at the last significant price pivot (high or low depending on the direction of the trade).  I identify these pivots points by adding the out-of-the-box  ”Pivot High” and “Pivot Low” TS ShowMe indicators to the chart (see the yellow ShowMes on this chart).  The green dotted line is the profit target.  This level is typically identified based on the key areas on the 576-tick chart and just carried over to the 144-tick chart.  Finally the yellow dotted line is my expected entry point for the trade.   As the trade is setting up I constantly adjust those three lines.  For instance it the chart plots a new pivot high, then I will move the red dotted line to the new pivot level.  Likewise if the price keep going up (and I am setting up for a short) I will keep adjusting the yellow line to the first possible entry point for the short.  I do this constantly so that when the trade is finally set up, all three lines are already properly placed for a quick risk/reward evaluation. For this I will look at the distance between the entry point and the stop loss (let’s call this R) also at the distance between the entry price and the profit target.  If this last distance is not at least 2R (or two times the distance between the entry point and the stop loss) then I just don’t take the trade.

This simple manual practice has kept me out of many losers and I use it for every single trade.

screenhunter_01-dec-14-2121

Plotting Equity

Since we have been talking a lot about automated strategies lately (or bots), it is useful to see that bot’s profitability on the chart along with the trades that it takes.  For this I have used two of the TS built-in functions, namely I_OpenEquity and I_ClosedEquity.  These functions can be used to return the values that you will find in the Net Profitability section of the Strategy Performance Report.  Now obviously one needs to look further than just net profitability in evaluating the overall performance of a strategy, so this is not the one and only measure to be used but it is an important measure nonetheless and one that can be rendered fairly easily on the bot’s chart for a quick review.

The indicator has been named TG_Equity and it’s capable of plotting the bot’s total net profitability over the trading period and/or its profitability for the current session. 

I have applied it to one of the FX bots (GBPJPY) for illustration purposes (see below).

screenhunter_01-dec-12-1709

With a quick glance we can see that on this day the bot had generated $1,346 of net profit and had a total net profitability of $13,605 over the evaluation period (20 days in this case).  If you have a high number of bots running at the same time, this indicator provides a ‘dashboard’ of sorts to quickly assess their individual performance.

The code is provided below:

inputs:
 iToday(true),
 iTotal(true),
 iProfitColor(green),
 iLossColor(red);
vars:
 vTodayEquity(0),
 vTotalEquity(0),
 vBODEquity(0),
 vTodayColor(green),
 vTotalColor(green);
if currentsession(0) <> currentsession(0)[1] then
begin
 vTodayEquity = 0 ;
 vBODEquity = I_OpenEquity ;
end ;
vTodayEquity = (I_OpenEquity - vBODEquity ) ;
vTotalEquity = I_OpenEquity;
vTodayColor = IFF(vTodayEquity>=0,iProfitColor,iLossColor);
vTotalColor =  IFF(vTotalEquity>=0,iProfitColor,iLossColor);
if iTotal then plot1(vTotalEquity,"Total",vTotalColor);
if iToday then plot2(vTodayEquity,"Today",vTodayColor);
plot3(0,"ZeroLine");

I like this FX bot

One of my bots (that’s how I call an automated strategy) has been doing pretty well on the FX.  It is based on a basic ’set-let’ strategy with fixed profit and stop loss targets based on the Hi-Lo charts that was presented in the earlier post.  The bot runs 24 hours a day from Sunday evening to Friday afternoon.  I have limited it to one trade at a time, but it will take both longs and shorts.  It identifies periods of overbuying and overselling and takes a trade on confirmed reversals.  A basic bot by all means but one that has been profitable.

The chart belows shows the equity curve over the last 20 days:

screenhunter_09-dec-11-1359

The TS performance analysis over the same period shows:

screenhunter_10-dec-11-1405So overall a good solid bot with bearable drawdown.  I am currently experimenting with different entry and exit filters to improve the profitability.  The attention so far has been primarily based on the entry filters to avoid the false breakouts.  I first experimented by setting a ‘Squeeze’ filter on the entry (Squeeze being defined as Bollinger Bands ranging with the Keltner channels).  If the bot triggered an entry signal with in Squeeze mode, I would delay the entry until the Squeeze was no longer true.  This approach unfortunately reduced the bot’s profitability and I abandonned it.  I am now experimenting with another entry filter that increases the breakout requirement (more demanding definition).  At this point the logic has been worked out, I now need to turn it into a function and apply it to the bot as a filter.  Stay tuned.

Plotting Candlesticks on indicators

TS offers about eight different plot styles for indicators but none of those include the candlestick.  However by combining histogram styles IN THE RIGHT ORDER one can achieve a similar look (a feature similar to Z-Order in higher end languages would be useful but it’s not currently available in TS so one has to order the plots properly in order to achieve a certain layering effect).

For me the need to plot candlesticks in an indicator appeared when I decided to plot a Hi-Lo chart of Forex pair daily pip excursions.  I use this chart to determine ‘most likely’ profit targets for Forex trades on any given day.  The chart is obtained by zeroeing the chart on the daily open (5:00pm) and plotting the High, Low, and Close relative to the Open, i.e. the relative High becomes the daily High – the daily Open and so forth.

The chart below  provides an example of the Hi-Lo chart applied to a daily GBPJPY pair.  The indicator’s price axis is expressed in pips.

screenhunter_07-dec-11-1223

You can use this chart to see what is the most likely excursion since early December for instance, i.e. the pip level that is most often reached.  In this case for December we could say that 200 pips is a likely first level target for trades as the pair has easily reached this excursion on a daily basis.  Another higher level may be 300 pips, which although it was reached less often since December, seems to be achievable on strong moving days.  The use of this Hi-Lo chart can therefore provide a more adaptive profit target setting technique that is based on relevant market volatility.  Here obviously there is no need to look at average excursions over the last year as the markets have morphed many different times over that period.  However a lookback period of a two to six weeks may be more representative of anticipated movements.

I have also made another improvement to this chart that will add text to the price chart that provides all the necessary monthly descriptive statistics (median, average, percentiles, etc) to help pinpoint the most likely daily excursion a bit more precisely (although outmost precision may not be the goal here).

TS hell

I have been pulling out the little hair I have left dealing with some annoying TS issues all day. The latest one has to do with the command line not recognizing any of my commands and constantly displaying the “Command Not Recognized” error dialog. After spending some time with technical support on the phone, and then eventually uninstalling all previous versions of TS and reinstalling the latest build, the problem still persisted. I was eventually able to find a fix in a dark corner of their online forum. For those of you who may be experiencing the same issue, exit TS, and run the following command: regsvr32 C:\WINDOWS\system32\vbscript.dll.
Then launch TS again and the problem should be fixed…
Where do they find those tech support guys?

New and improved MACD BB

The MACD BB is a beautiful instrument to identify divergences, reaction to support and resistance areas, and the strength or weakness of a move.  I use it every single day as part of my trading strategy for the @ES.  I have recently made some cosmetic improvements to the indicator, more specifically I have added a link between the dots and gave the dots a shadow that makes them more visible.  The link is also valuable in gauging the spacing and angle of the MACD dots which is itself useful in evaluating some of my setups.  If you use this make sure that the scaling of the indicator is always set to automatic.  The example below shows the application of the indicator to the @ES 576-tick chart which is also my primary trading chart (setup identification and targets).  I also apply it to my 144-tick chart which is used for entries and stop loss setting.

screenhunter_11-dec-09-0228

screenhunter_12-dec-09-0229

Trading the tick

Freshly returned from a two-day Tradestation class entitled ‘Mastering EasyLanguage For Strategies’, I have decided to implement John Carter’s Tick Fade strategy from his book ‘Mastering The Trade’ and his DVD ‘Market Internals’.  The strategy is fairly straightfoward which is perfect as a programming exercise:

  • If the $Tick exceeds +1000, fade the market and go short.
  • If the $Tick is below -1000, fade the market and go long.
  • He uses a 3-point stop and a 2-point profit target for the @ES (E-mini S&P 500) and a 35-minute timed exit .
  • He also recommends turning off the strategy if a trend forms early in the day, as defined by over 90% of Tick values being above zero, or below zero, during the first half hour of the day (from 9:30am to 10:00am).  Indeed this strategy is meant to be used on ‘choppy’ days only.
  • Lastly, the strategy runs from 10:00am to 3:30pm to avoid the big institutional moves a the end of the day.

Here is the code for the strategy:

{
--------------------------------------------------------------------------------
Tick Fade Strategy
--------------------------------------------------------------------------------
Developed by Trader2Be (trader2be@gmail.com)
http://tradersguild.wordpress.com
Inspired by Trade The Markets
--------------------------------------------------------------------------------
Version 1.0 - 12/5/2008 - Initial Implementation
Version 2.0 - 12/8/2008 - Includes directional filter and timed exits
--------------------------------------------------------------------------------
Chart Requirements:
 - 1 min chart of @ESZ08 (or later) or other futures, as sub-graph 1, set to local time
 - 1 min chart of $TICK, as sub-graph 2, set to local time
}
inputs:
    iVersion("2.0"),
    iContracts(1), 
    iFadeTrigger(1200),
    iStopLoss(2),
    iProfitTarget(3),
    iDirectionEvalStart(0930),
    iDirectionEvalEnd(0959),
    iTradingStartTime(1000),
    iTradingEndTime(1530),
    iMaxTradeDuration(35),
    iBiasLevel(.8);

vars:
    vUp(0),
    vDown(0),
    vRatioUp(0),
    vRatioDn(0),
    vBarCnt(0),
    vTradeOK(false),
    vBarToExit(0),
    vIDText(0),
    vTextPrint(false);

// Directional Filter
if date <> date[1] then
begin
    vUp = 0;
    vDown = 0;
    vBarCnt = 0;
    vTradeOK = false;
    vTextPrint = true;
end;

if time >= iDirectionEvalStart and Time <= iDirectionEvalEnd then
begin
    vBarCnt = vBarCnt + 1;
    if L of Data2 > 0 then vUp = vUp + 1
        else if H of Data2 < 0 then vDown = vDown + 1;
end else
begin
    if (vUp+vDown) > 0 then
        begin       
            vRatioUp = vUp/(vBarCnt);
            vRatioDn = vDown/(vBarCnt);
            if vRatioUp >= iBiasLevel then  vTradeOK = false else
                if vRatioDn >= iBiasLevel then vTradeOK = false else
                    vTradeOK = true;
        end
    else vTradeOK = true;
    if vTextPrint then
    begin
        vIDText = Text_New(date,time,H,IFFString(vTradeOK,"Enabled","Disabled"));   
        vTextPrint = false;
    end;
end; 

// Time Exit

if BarType = 1 AND BarInterval < iMaxTradeDuration then
begin
    vBarToExit = round(iMaxTradeDuration/BarInterval,0);
    print (vBarToExit);
end
    else vBarToExit = 0;

// Trade

if vTradeOK then
begin
    Condition1 = (Time > iTradingStartTime);
    Condition2 = (Time < iTradingEndTime);
    Condition3 = (H of Data2) > iFadeTrigger;
    Condition4 = (L of Data2) < -iFadeTrigger;

    if (Condition1 and Condition2 and (MarketPosition(0) = 0)) then
    begin
        if Condition3 then sellshort ("TF_SE") iContracts Contracts this bar on close;
        if Condition4 then buy ("TF_LE") iContracts Contracts this bar on close;
    end;

    if (MarketPosition(0) = 1) then
    begin
        sell ("TF_LE_SL") iContracts Contracts next bar at (EntryPrice - iStopLoss) stop;
        sell ("TF_LE_PT") iContracts Contracts next bar at (EntryPrice + iProfitTarget) limit;
    end;

    if (MarketPosition(0) = -1) then
    begin
        buytocover ("TF_SE_SL") iContracts Contracts next bar at (EntryPrice + iStopLoss) stop;
        buytocover ("TF_SE_PT") iContracts Contracts next bar at (EntryPrice - iProfitTarget) limit;
    end;

    //Time Exits

    if (MarketPosition(0) = 1) and (BarsSinceEntry(0) = vBarToExit)  then
        sell ("TF_LE_TX") iContracts Contracts next bar at market;

    if (MarketPosition(0) = -1) and (BarsSinceEntry(0) = vBarToExit)  then
        buytocover ("TF_SE_TX") iContracts Contracts next bar at market;

end;

The chart belows shows the strategy applied to the @ES (sub graph 1) with the $Tick as a sub graph 2.  Signal lines have been manually added to the $tick for debugging purposes.

screenhunter_07-dec-08-1639

Now, here is the big question: IS THIS STRATEGY PROFITABLE???

To answer this question, I have used default parameter values, namely:

screenhunter_08-dec-08-1642

With these parameters, by backtesting the strategy over the last 20 days, we obtain the following results:

screenhunter_10-dec-08-1646

My next step is to learn to analyze those trade results.  At first glance it looks good with a 75% profitable and $3,260 of profit on a single contract after 20 days of trading.  But the devil may be in the details.  More to follow.