# Time based gold short EA?



## sinner (24 February 2009)

Hi guys,

Despite being a CompSci grad with plenty of programming experience in the real world I have never looked at the many platforms people seem to use here for EAs and similar.

However, some back of envelope calculations (and I stress, back of envelope) give a high statistical probability of low risk/decent gains for this idea I had.

Place a short on spot gold at the end of NYMEX trading with stoploss at the NYMEX high.

Exit at the end of the Sydney trading session.

Would like to see how it turns out.

I am guessing this would not be too hard to code, anyone willing to give it a shot with some quick backtests?


----------



## sinner (24 February 2009)

Hi guys,

I have attempted something along the lines of what was outlined above. In the end the "good" timeframes were actually completely different from what I expected.

I settled with go short (and exit longs) at 1900 AEST, then exit shorts (and go long) at 0400 AEST.

The first one is just go short at 1900 AEST and exit at 0400 AEST.

In both charts, the top section is equity, second is position duration, third is buy/sell on chart and fourth is timeframe indicator.

A hard 10 point stop loss coded in, no take profit.

The starting capital is 10,000 but you could do the same thing with gold mini and 1000 starting dollars.

Here is the code for the timeframe indicator

```
If Hour = 19 AND Minute = 0 THEN
	Result = 1
ELSIF Hour = 4 AND Minute = 0 THEN
	Result = -1
ELSE
	Result = 0
ENDIF
Return Result AS "Ind"
```

Here is the code for the backtest majigger


```
REM Short

indicator1 = CALL timegoldshort

IF indicator1 = 1 THEN
	SELLSHORT 1 SHARES AT MARKET THISBARONCLOSE
	SELL AT MARKET THISBARONCLOSE
ENDIF

REM Exit short

IF indicator1 = -1 THEN
	EXITSHORT  AT MARKET THISBARONCLOSE
	BUY 1 SHARES AT MARKET THISBARONCLOSE
ENDIF
```

Very rudimentary as you can see.

Any comments?

I wanted to test it from March 1 08 to current day but my IG hourly charts only seem to go back to Jan. Anyone up for the task?


----------



## sinner (24 February 2009)

Sorry to keep posting. 

You can see the drawdowns in the second chart because we are going long against the short term trend is down.

A simple addition of 20MA or Bollinger indicator to decide whether to go long or just not exit the entered short would take care of trending up or down markets.

The main thing I am trying to point out is that even during the gold bull market certain timeframes have a statistically significant chance of being selling periods and someone could try to capitalise on this.


----------



## Trembling Hand (25 February 2009)

sinner said:


> The main thing I am trying to point out is that even during the gold bull market certain timeframes have a statistically significant chance of being selling periods and someone could try to capitalise on this.




These things turn up all the time. If you shorted the SPI from 03 to 07 during cash hours every day you would be driving a Ferrari now. Thats during a raging Bull market.


----------



## peter2 (25 February 2009)

In markets that trade nearly 24hrs (like gold and many others) there is a high volume session and a low volume session. Most of the movement of price is during the high volume session when the US markets are open. [ TH has posted some research on this using the SPI. ] There is an increase in volume during the UK open relative to the Asian session and price may move during this time. You may have noticed that price tends to retrace during the low volume Aust/Asian session. This doesn't happens every day but is it often enough to be profitable? 

Trading during the low volume session has additional risks and one must be prepared for the occasional price spike that can be caused by one large order being filled.


----------



## sinner (25 February 2009)

Hi again guys,

Last post for the night, I promise to stop pestering you!

Here is a slightly more conservative system, with a -0.5 weighted price oscillator indicator to stop it from going long against the trend.

This makes the system very short biased and reduces the profit a bit from a less conservative play, but also smooths out the equity line a lot more!

Have placed hard stop at 10 points and take profit of 25.5 points i.e. max risk reward per contract is 1:2.55. We have to consider the system only has 1 contract open at a time, there is no position sizing to take advantage of compounded gains or losses. Also it won't extend the short if the intermediate trend happens to be downwards. If a bear market in gold eventuates this would be essential.

As you can see the expectancy for shorts is a lot lower than longs, because they are not supported by any indicator only my arbitrary time frames. But I think the fact stop-loss never hit on the shorts (see max loss for shorts) indicates there is some feasibility to the idea.

timegoldshort indicator

```
If Hour = 19 AND Minute = 0 THEN
	Result = 1
ELSIF Hour = 5 AND Minute = 0 THEN
	Result = -1
ELSE
	Result = 0
ENDIF
Return Result AS "Ind"
```

priceosc indicator

```
RETURN PriceOscillator[5,25](close) - 0.5
```

timegoldshort

```
REM Short

indicator1 = CALL timegoldshort
indicator2 = CALL priceosc
long = 0

IF indicator1 = 1 THEN
	SELLSHORT 1 SHARES AT MARKET THISBARONCLOSE
	IF indicator2 > 0 AND long = 1 THEN
		SELL 1 SHARES AT MARKET THISBARONCLOSE
		long = 0
	ENDIF
ENDIF

REM Exit short

IF indicator1 = -1 THEN
	EXITSHORT AT MARKET THISBARONCLOSE
	IF indicator2 > 0 AND long = 0 THEN
		BUY 1 SHARES AT MARKET THISBARONCLOSE
		long = 1
	ENDIF
ENDIF
```

Would really like to see this tested over a longer timeframe but like I said my charts don't go back that far. Anyone willing to help me out? Would be much appreciated!


----------



## Trembling Hand (25 February 2009)

I think I have all(with the odd hole) of 08 GC gold in 1 min Ninja trader format.

20080508 003400;866.0;866.3;865.8;866.3;20
20080508 003500;866.5;866.9;866.5;866.5;9
20080508 003600;866.7;867.2;866.5;866.9;36
20080508 003700;866.8;867.1;866.4;866.7;72
20080508 003800;866.8;866.8;865.5;865.5;29
20080508 003900;865.5;866.0;864.3;866.0;169

All melb time.


----------



## lindsayf (25 February 2009)

TH where do you get that much data..via the NT market recorder..or elsewhere?
thks


----------



## Trembling Hand (25 February 2009)

lindsayf said:


> TH where do you get that much data..via the NT market recorder..or elsewhere?
> thks




Yeah by just being connected through NT. It stores it.


----------



## lindsayf (25 February 2009)

so you have a dedicated PC recording 24 hrs...or more than 1?  You can have multiple charts open and record them all cant you....hmmmmm


----------



## Trembling Hand (25 February 2009)

lindsayf said:


> so you have a dedicated PC recording 24 hrs...or more than 1?  You can have multiple charts open and record them all cant you....hmmmmm




If you just want the data you do a back fill. If you want to use the recording and replay function then you have to have it up and running with a chart or in a watch list. & DOM if you want that too.


----------

