/ 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 0700 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
reverse = 0
ENDIF
// RANGE between 0700h to 0800h
IF TIME=080000 THEN
channelhigh = Highest[4](high)
channellow = Lowest[4](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 NOT ONMARKET AND Operationaltime AND tradeok = 1 AND alreadytraded=0 THEN
BUY 1 CONTRACT AT channelhigh + 3*pipsize STOP
alreadytraded=1
reverse=1
ENDIF
// SHORT Positions-Opening
IF NOT ONMARKET AND Operationaltime AND tradeok = 1 AND alreadytraded=0 THEN
SELLSHORT 1 CONTRACT AT channellow - 3*pipsize STOP
alreadytraded=2
reverse=1
ENDIF
// TEST IF AN ORDER IS IN THE MARKET
IF ONMARKET THEN
tradeok = 0
alreadytraded = 1
ENDIF
// REVERSE
IF reverse=1 THEN
IF alreadytraded=1 AND NOT ONMARKET AND POSITIONPERF(1)<0 THEN
SELLSHORT 1 CONTRACT AT MARKET
reverse=0
ENDIF
IF alreadytraded=2 AND NOT ONMARKET AND POSITIONPERF(1)<0 THEN
BUY 1 CONTRACT AT MARKET
reverse=0
ENDIF
ENDIF
// STOP & PROFIT
SET STOP LOSS 5*pipsize
SET TARGET PROFIT 8*pipsize
Hi everyone,
I posted this same code yesterday, and out of the blue (I don’t know why) now it does not operate everyday.
It is a very simple breakout system with a reverse stop in case that the first trade does not work.
The only problem is that only launches an average of 5-6 operations a month. I am playing with the INTRADAYBARINDEX command but nothing.
Thanks a lot,
Juan
Hi Juan, I answered your question in the other thread here: https://www.prorealcode.com/topic/help-identifying-a-mistake-in-this-simple-code/
Is this the same problem?
Hi Nicolas,
Yes and yes. You gave me a solution yesterday but it didn´t seem to work completely. I have a tried to fixed myself but I don’t know why, the system doesn’t launch operations everyday.
Ideally, it should launch one order (everyday after 08:00) once the price breaks the upper or lower limit of the channel formed with the range of the previous candlesticks (from 07:00 to 08:00), and in case of a negative outcome, it launches a reversal order after the stop loss is closed. That is it. No more trading until next day.
I made it (with your instructions) to trade once a day and to launch a reversal order after the first stop loss, but somehow it only works 10 days a month. I have also removed the Maximum Range of 32 pips for the Channel, but that is not the problem.
Thanks,
Juan
As I wrote yesterday in the other topic, you have to set your pending order at each bar .. but you disallow them after only 1 bar with your lines 36 and 44. So if the price doesn’t breach your upper or lower levels at the first bar, you’ll never get trade the rest of the day, because no new pending STOP orders are set!
Hi Nicolas,
Sorry, I will pay more attention next time. You are completely right!!! It works!!! I was just right there.
Thanks,
Juan