Hi anyone knows how to code a strategy to
If the open volume (volume of the first 1 min bar) is higher than the average open volumes (volume of the first 1 min bars ) of the past 10 days then
if it opens 2% higher than past 10 days highest , buy at the market . If stock opens 2% lower than the lowest of the past 10 days sell short at market.
Thanks
Thanks for reply. The problem is the volume, if we say volume > average (10) volume. If it is comparing the whole day volume. It will not show the gap stock in the screener probably until the end of the trading day where the volume reach to the above average of past 10 days.
For strategies it is possible to average only the first minute for each of the last 10 days, as they support 200K units, which provides roughly 6 months of data history.
I will code it asap.
For Screener , if it is 246 bar only , is it possible to compare the volume of the first 20 minutes bar of the last 10 days?
You can test this one (on 1-minute TF):
DEFPARAM CumulateOrders = False
DEFPARAM PreLoadBars = 10000
//
Timeframe(1 minute,default)
CheckTime = 090000 //First minute
N = 10 //10 days
LotSize = 100 //100 shares
Timeframe(Daily,UpdateOnClose)
LL = lowest[N](low)
HH = highest[N](high)
//
Timeframe(Daily,Default)
c1 = 0
c2 = 0
c1 = open >= (HH[1] * 1.02) //previous high + 2%
c2 = open <= (LL[1] * 0.98) //previous Low - 2%
//
Timeframe(1 minute,UpdateOnClose)
t = 0
VL = 0
IF BarIndex <=1 THEN
FOR j = 1 TO N
$VL1[j] = 0
NEXT
ENDIF
IF OpenTime = CheckTime THEN
Tally = 0
FOR j = N DOWNTO 2
Tally = Tally + $VL1[j]
$VL1[j] = $VL1[j - 1]
NEXT
$VL1[1] = volume
Tally = Tally + volume
FirstMINUTE = Tally / N
ENDIF
//
Timeframe(1 minute,default)
c3 = 0
IF (BarIndex >= (N * 1440)) AND (OpenTime = CheckTime) THEN
c3 = volume > FirstMINUTE
IF c3 THEN
IF c1 AND Not OnMarket THEN
BUY LotSize CONTRACT AT Market
ENDIF
IF c2 AND Not OnMarket THEN
SELLSHORT LotSize CONTRACT AT Market
ENDIF
SET TARGET pPROFIT 300
SET STOP pLOSS 100
ENDIF
ENDIF