Hi Colleagues,
I am posting this strategy well known by most of you, but with some slight modifications. I would APPRECIATTE if someone could identify what is wrong.
It seems to work but I cannot get all the conditions right in the backtest. I am new with programming, and I am frustrated with this system because I cannot get one operation everyday, or when I get it, the system is launching the orders at the same time everyday, etc.
The system is a simple morning breakout for EUR-USD (TF: 15 min).
1.Starts at 08:00h and collect the highest and lowest from the last 12 candlesticks (from 05:00 to 08:00h).
2. After 08:00h, when the price breaks the highest of the channel + 3 pips, or the lowest of the channel– 3 pips, buy long or sell short (in the same candle, not at the opening of the next candle).
3. Stops and Target Profits finish the trading.
4. Only operates once a day, regardless if the trade was positive or negative.
5. The system will shut down at 14:00h. Any open trade will be close at that time.
6. I have included a NON OPERATING condition, in case the range of the channel of the 12 candlesticks is bigger than 32 pips.
Although it seems very basic and the equity curve is not very attractive right now, I like the fact that I can control the operations once a day and limit and daily monitoring the results. It is a matter of adding other currencies everyday, and creating different schedules for US and Asian markets (i.e.- I could have 5 currencies from 0800 to 1400, 5 from 1500 to 2200, and other five overnight for Asian market). It is just a matter, once it works, to change the time in the code).
Thanks so much in advance,
Juan
// FOREX BREAKOUT
// 15 MIN
// One trade per day, from 08:00h to 14:00. The system shuts-down at 14:00h
// Everyday Channel formation from 0500 to 0800 (Highest-Lowest)
// Maximum Range 32pips
DEFPARAM CUMULATEORDERS = false
// OPERATIONAL TIME
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 140000
Operationaltime = TIME > 080000 AND TIME < 140000
// ONE TRADE PER DAY. It resets the variable each new day
IF INTRADAYBARINDEX = 0 THEN
alreadytraded = 0
ENDIF
// RANGE between 0500h to 0800h
IF TIME=080000 THEN
channelhigh = Highest[12](high)
channellow = Lowest[12](low)
ENDIF
// NO ACTIVITY if the range (highest-lowest)is >= 32 pips
IF channelhigh-channellow>=32*pipsize THEN
tradeok=0
ELSE
tradeok=1
ENDIF
// LONG Positions-Opening
IF Operationaltime AND tradeok = 1 AND alreadytraded = 0 THEN
BUY 1 CONTRACT AT channelhigh + 3*pipsize STOP
tradeok = 0
alreadytraded = 1
ENDIF
// SHORT Positions-Opening
IF Operationaltime AND tradeok = 1 AND alreadytraded = 0 THEN
SELLSHORT 1 CONTRACT AT channellow - 3*pipsize STOP
tradeok = 0
alreadytraded = 1
ENDIF
// STOP & PROFIT
SET STOP LOSS 8*pipsize
SET TARGET PROFIT 12*pipsize