Hi,
I’m using the code below. There is just one thing I want to change. I don’t want the order to start on ‘close’ but I want the order to start when the price hits “orderhigh” or “orderlow”. What do I have to adjust in the code below?
// RANGE between 0000h to 0600h
IF TIME=060000 THEN
channelhigh = Highest[12](high)
channellow = Lowest[12](low)
ENDIF
// orderlines 3.5
orderhigh= channelhigh + 3.5*pipsize
orderlow= channellow - 3.5*pipsize
// BREAKOUT Conditions
c1= close > orderhigh
c2= close < orderlow
// LONG Positions-Opening
IF Operationaltime and c1 AND alreadytraded = 0 THEN
BUY 10 CONTRACT AT MARKET
alreadytraded = 1
ENDIF
// SHORT Positions-Opening
IF Operationaltime and c2 AND alreadytraded = 0 THEN
SELLSHORT 10 CONTRACT AT MARKET
alreadytraded = 1
ENDIF
You have to use pending STOP orders:
if onmarket then
alreadytraded=1
endif
// RANGE between 0000h to 0600h
IF TIME=060000 THEN
channelhigh = Highest[12](high)
channellow = Lowest[12](low)
ENDIF
// orderlines 3.5
orderhigh= channelhigh + 3.5*pipsize
orderlow= channellow - 3.5*pipsize
// LONG Positions-Opening
IF Operationaltime AND alreadytraded = 0 THEN
BUY 10 CONTRACT AT orderhigh stop
//alreadytraded = 1
ENDIF
// SHORT Positions-Opening
IF Operationaltime AND alreadytraded = 0 THEN
SELLSHORT 10 CONTRACT AT orderlow stop
//alreadytraded = 1
ENDIF
Because we can’t know in advance when the order is triggered, the “alreadytraded” variable is to test only when you are on market (and at the beginning of the code, to prevent new pending order while already at market and because the code is read from top to bottom).