Hi, I am using v10.3. I need an open price at 08:00 and highest and lowest prices between 08:00 and 09:00 for N days.
if time=080000 then
initialOPEN=open
endif
once sup=0
once infer=100000
if time>=080000 and time <=090000 then
if high>sup then
sup=high
endif
if low<infer then
infer=low
endif
endif
return initialOPEN, sup, infer
Hallo, gabri,
thank you very much for your help!
How can I calculate min and max for x = sup-initialOPEN and y = initialOPEN-infer as average values for 22 days?
Hallo, gabri,
I have corrected the previous post:
How can I calculate x = sup-initialOPEN and y = initialOPEN-infer as average values for 22 days?
I am not sure you can do that in an intraday window, sorry!!
Roman, do you need a simple average and ONLY in one specific timeframe? If so tell me the timeframe and I might be able to do something.
Hi, gabri,
For example: the average value as diffence between open price and highest price (highest price – open price) between 080000 and 090000 (DL on the picture) for last 22 days and the avergae value as diffence between open price and lowest price (open price – lowest price) between 080000 and 090000 (DS on the picture) for last 22 days.
Roman,
if for you a Wilder Average is enough I can offer you this solution. If you need a standard average I need to come up with something more complex.
//Timeframe used has to be less than 1 hr
//definition open of the day
initialopen=dopen(0)
//computation max and min in the first hour - super e infer
if (time>=090000) and (time<=100000) then
super=dopen(0)
infer=dopen(0)
if high>super then
super=high
endif
if low<infer then
infer=low
endif
else
super=super
infer=infer
endif
//computation Wilder average of (super-initialopen) and (initialopen-infer)
period=22
once sommadeltasuper=0
once sommadeltainfer=0
if time=100000 then
sommadeltasuper=((super-initialopen)+(sommadeltasuper*(period-1)))/period
sommadeltainfer=((super-initialopen)+(sommadeltasuper*(period-1)))/period
endif
return sommadeltasuper,sommadeltainfer
Roman,
this is the code with simple moving average. Let me know how it work.
//computation timeframe in use and intraday number of bars - intrab
if intradaybarindex=0 then
time1=opentime
endif
if intradaybarindex=1 then
time2=opentime
endif
deltatime=(time2-time1)/100
intrab=round(522/deltatime)
//computation max and min in the first hour - super e infer
if (time>=090000) and (time<=100000) then
super=dopen(0)
infer=dopen(0)
if high>super then
super=high
endif
if low<infer then
infer=low
endif
else
super=super
infer=infer
endif
//computation average (super-initialopen) and (initialopen-infer)
period=20
if time=100000 then
sommadeltasuper=0
sommadeltainfer=0
for i=0 to (period) do
j=1+round(i*intrab)
sommadeltasuper=sommadeltasuper+abs(super[j]-dopen(i))
sommadeltainfer=sommadeltainfer+abs(dopen(i)-infer[j])
next
deltasuper=sommadeltasuper/period
deltainfer=sommadeltainfer/period
endif
if time>100000 then
up=super+deltasuper
down=infer-deltainfer
else
up=up
down=down
endif
return up,down
With this last code you can directly insert the program over the price and see the lines.
Roman,
take your time and check if the indicator works as needed. In case it gives the result you were looking for let me know so that I can post it also for the others.
Hallo, gabri,
you can see attached results. I used your Wilder’s Average. The idea was that in the premarket (08.00 – 09:00) the price often returns to the open price at 08:00. I don’t think the code can be improved, so I reject the idea.
Thank you
Roman
Roman,
I understand that the strategy you planned didn’t return the results you wanted. Was the indicator fulfilling your needs? did it show the data you needed?
Gabriele
gabri,
your indicator completely fulfilled my needs, thank you!
Roman