Hi Guys,
Would any of you wizards be able to create a pro order strategy using an adjustable timeframe but mainly 1 minute and 5 minute using the VWAP indicator.
Buy Conditions
Condition 1
Price crosses above VWAP
Condition 2
Next bar closes higher than the VWAP
execute order at next bar
Sell (Short) Conditions
The exact opposit of the Buy Condition
Exit Conditions
Still toying with this but would like the ability to backtest different variatons of a trailing stop by pips, % and value.
That below code should trigger the orders based on the VWAP cross you described:
if day<>day[1] then
d=0
else
d=d+1
if volume >0 then
VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
endif
endif
if close crosses over vwap then
buybar=barindex
endif
if close crosses under vwap then
sellbar=barindex
endif
if barindex-buybar=1 and not longonmarket then
if close > vwap then
buy at market
endif
endif
if barindex-sellbar=1 and not shortonmarket then
if close < vwap then
sellshort at market
endif
endif
set stop ptrailing 15 //change to whatever kind of trailing stop here: ptrailing, %trailing
Change the trailing stop instruction to the desired one (last line of the code).
Thank you @Nicolas
This is exactly what I wanted perfect! just one question around the position sizing. I did not see an element within the code that allows what the entry position size should be?
change line 20 with “buy 1 contract at market”, do the same for the sellshort order.