Hello,
Silly question but I can’t figure it out right now after a busy day.
I would like to introduce in a strategy the high and low of the previous day for an index such as the dowjones, but only during the cash market hours… It’s pretty easy to do it for an indicator, but I don’t know why this isn’t working in proorder.
if time >=153000 and time<=220000 and date=yesterday then
myHigh=max(myHigh , high)
myLow= min(myLow , low)
endif
Any idea why myHigh/myLow are undefined?
DATE can never equal YESTERDAY.
This might help:
Customized Trading session
Thx Vonasi, always quick on the ball!
investigating a new strat based on the the open, close, and the interaction of price with vwap intraday
Vonasi, as you helped me, here is MAYBE your reward…
this was not the idea I had in mind a few hours back, but the results are not bad. Tested on Dow Jones 1min, on 200k. Unfortunately, not enough history to really know if this is profitable strategy. Maybe someone who has already access to V11 with millions of bars of history?
DEFPARAM FlatAfter = 215900
DEFPARAM cumulateorders=false
ONCE positionsize=1
// The 24th and 31th days of December will not be traded because market close before 7h45 PM
IF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THEN
TradingDay = 0
ELSE
TradingDay = 1
ENDIF
if intradaybarindex=0 then
Longtradecounter = 0
Shorttradecounter = 0
long=0
short=0
endif
//to account for daylight hour change (to update every year)
if (month=3 and day<31 and day>10) then
starttime=143000
endtime=210000
else
starttime=153000
endtime=220000
endif
tradetime=time >=starttime+1500 and time < endtime and dayofweek<>0 and tradingday
if time = starttime then
op = open
lo = low
hi = high
endif
if time = endtime then
//lastop = op
lasthi = hi
lastlo = lo
lastcl = close
endif
if time >= starttime+100 and time < endtime then
hi = max(hi,high)
lo = min(lo,low)
endif
maxi=max(max(op,lastcl),lasthi)
mini=min(min(op,lastcl),lastlo)
if close crosses over maxi and time >= starttime+1500 and time < endtime then
long=1
endif
if close crosses under mini and time >= starttime+1500 and time < endtime then
short=1
endif
myMA7=average[7](close)
if tradetime and not onmarket then
if long=1 and myMA7[1]<myMA7[2] and myMA7>myMA7[1] and Longtradecounter < 1 then
buy positionSize contracts at highest[5](high)+3*pointsize STOP
endif
if short=1 and myMA7[1]>myMA7[2] and myMA7<myMA7[1] and Shorttradecounter < 1 then
sellshort positionSize contracts at lowest[5](low)-3*pointsize STOP
endif
endif
graph longtradecounter
if longonmarket then
Longtradecounter=Longtradecounter+1
endif
if shortonmarket then
Shorttradecounter=Shorttradecounter+1
endif
//if longonmarket and low=lastlo then
//sell at low-3*pointsize STOP
//endif
//
//if shortonmarket and high=lasthi then
//exitshort at high+3*pointsize STOP
//endif
//graphonprice lastcl
//graphonprice op
//graphonprice lasthi
enablets=1 // mettre à 1 pour activer le trailing stop, sinon 0
ts1=0.15 //trailing stop qui commence une fois que ts1% est atteint, puis quand la perf atteint ts2+ts3, diminué à ts2, puis quand la perf=ts1+ts2, placé à ts3
ts2=0.125
ts3=0.10
if enablets then
switch =ts2+ts3
switch2=ts1+ts2
underlaying=100
// underlaying security / index / forex
// profittargets and stoploss have to match the lines
// not to be optimized
// 0.01 forex [i.e. gbpusd=0.01]
// 1.00 securities [i.e. aapl=1 ;
// 100.00 indexes [i.e. dax=100]
// 100=xauusd
// 100=cl us crude
trailingstop1 = (tradeprice(1)/100)*ts1
trailingstop2 = (tradeprice(1)/100)*ts2
trailingstop3 = (tradeprice(1)/100)*ts3
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
maxprice1=0
minprice1=close
priceexit1=0
maxprice2=0
minprice2=close
priceexit2=0
maxprice3=0
minprice3=close
priceexit3=0
a1=0
a2=0
a3=0
pp=0
endif
if onmarket then
pp=(positionperf*100)
if pp>=ts1 then
a1=1
endif
if pp>=switch then
a2=1
endif
if pp>=switch2 then
a3=1
endif
endif
// setup long
if longonmarket then
maxprice1=max(maxprice1,high)
maxprice2=max(maxprice2,high)
maxprice3=max(maxprice3,high)
if a1 then
if maxprice1-tradeprice(1)>=(trailingstop1)*pointsize then
priceexit1=maxprice1-(trailingstop1/(underlaying/100))*pointsize
endif
endif
if a2 then
if maxprice2-tradeprice(1)>=(trailingstop2)*pointsize then
priceexit2=maxprice2-(trailingstop2/(underlaying/100))*pointsize
endif
endif
if a3 then
if maxprice3-tradeprice(1)>=(trailingstop3)*pointsize then
priceexit3=maxprice3-(trailingstop3/(underlaying/100))*pointsize
endif
endif
endif
// setup short
if shortonmarket then
minprice1=min(minprice1,close)
minprice2=min(minprice2,low)
minprice3=min(minprice3,low)
if a1 then
if tradeprice(1)-minprice1>=(trailingstop1)*pointsize then
priceexit1=minprice1+(trailingstop1/(underlaying/100))*pointsize
endif
endif
if a2 then
if tradeprice(1)-minprice2>=(trailingstop2)*pointsize then
priceexit2=minprice2+(trailingstop2/(underlaying/100))*pointsize
endif
endif
if a3 then
if tradeprice(1)-minprice3>=(trailingstop3)*pointsize then
priceexit3=minprice3+(trailingstop3/(underlaying/100))*pointsize
endif
endif
endif
// exit long
if longonmarket then
if priceexit1>0 then
sell at priceexit1 stop
endif
if priceexit2>0 then
sell at priceexit2 stop
endif
if priceexit3>0 then
sell at priceexit3 stop
endif
endif
// exit short
if shortonmarket then
if priceexit1>0 then
exitshort at priceexit1 stop
endif
if priceexit2>0 then
exitshort at priceexit2 stop
endif
if priceexit3>0 then
exitshort at priceexit3 stop
endif
endif
endif
//displayts=0
//
//if displayts and priceexit1<>0 then
//graphonprice priceexit1 coloured(0,0,255,255) as "trailingstop1"
//endif
//if displayts and priceexit2<>0 then
//graphonprice priceexit2 coloured(0,0,255,255) as "trailingstop2"
//endif
//if displayts and priceexit3<>0 then
//graphonprice priceexit3 coloured(0,0,255,255) as "trailingstop3"
//endif
//SET TARGET %profit 0.12
SET STOP %loss 0.5
@stefou102
Why not make a quick test on 1M bars with PRT v11? (Dow Jones index).
Would love to, but I have prt via IG, so no access to v11, and in demo I see only data with TF>day…