Trick in finding Support/Resistance point
Posted: Sat Jan 20, 2007 10:51 am
In designing a long term trading system, I was looking for a way to identifie the Support price point once I was in the trade.
I had decide that a resistance point could be identifie when a number (n) of Bar in both side of a past bar had a Higher Low. So if I am looking for a support with 4 bar on both side, I would then have a loop that look in the last 500 bar for the first point in time where I had a bar with 4 higher low on each side. This would then constitute my support point.
This involve 2 imbricate loop, one that go back in time, up to 500 bar or until I found my support.
And another one that every day check 4 bar on each side, to test for the Highest Low.
this code basically do that.
//////////////////////////////////////////////////////////////
'
' Find the Low Turning point
'
StillTrue = TRUE
MaxLookBack = 500
Looker = -1
LowTurningPointPrice1 = 0
LowTurningPointPrice2 = 0
DO
StillTrue = TRUE
Looker = Looker + 1
BackOffset = SwingLen + Looker
FOR i = 0 to SwingLen
IF StillTrue = TRUE THEN
IF instrument.Low[BackOffSet] > instrument.Low[BackOffSet-i] OR _
instrument.Low[BAckOffSet] > instrument.Low[BackOffSet+i] THEN
StillTrue = FALSE
ENDIF
ENDIF
NEXT
IF StillTrue = TRUE THEN
LowTurningPointPrice1 = instrument.Low[BackOffset]
LowTurningPointDate1 = datetojulian(instrument.Date[BackOffset])
LowTurningPointBar1 = instrument.Bar[BackOffset]
ENDIF
LOOP UNTIL Looker > MaxLookBack OR LowTurningPointPrice1 <> 0
//////////////////////////////////////////////////////////////////////
You may have a fast CPU this take a lot of time to compute.
------
I then had this dream that this could be resolve like this. You create an IPV Series where you just do the following.
You create an IPV Series variable and on you Entry Order you assign its previous day value and you check against the Lowest low of double the period you are looking.
Ex: I want the latest price where I had 4 day with highest Low on each side. So: Dip = 4
LastLowDipPrice = LastLowDipPrice[1] ' My IPV Series variables
'
' Now find the latest Dip Point
'
if instrument.Lowest("Low",Dip*2+1) = instrument.Low[Dip+1] THEN
LastLowDipPRice = instrument.Low[Dip+1]
endif
///////////////////////////
Voila!! You have an IPV Series that carry your latest support price.
If you want to search for a Support where you had 6 day on the left and 3 on the right. Market start to bounce from a retracement type.
You would nead 2 variables MaxDipLength and DipPOint
LeftDipLength=6
RightDipLength = 3
if instrument.Lowest("Low",LeftDipLength+RightDipLength+1) = instrument.Low[RightDipPoint+1] THEN
LastLowDipPRice = instrument.Low[RightDipPoint+1]
endif
////////////////////////
This will compute probably 50 times faster. and obviously you can reverse that to find the resistance point.
//////////////
Here is sample output of the IPV Series with a 5 day Dip point
I had decide that a resistance point could be identifie when a number (n) of Bar in both side of a past bar had a Higher Low. So if I am looking for a support with 4 bar on both side, I would then have a loop that look in the last 500 bar for the first point in time where I had a bar with 4 higher low on each side. This would then constitute my support point.
This involve 2 imbricate loop, one that go back in time, up to 500 bar or until I found my support.
And another one that every day check 4 bar on each side, to test for the Highest Low.
this code basically do that.
//////////////////////////////////////////////////////////////
'
' Find the Low Turning point
'
StillTrue = TRUE
MaxLookBack = 500
Looker = -1
LowTurningPointPrice1 = 0
LowTurningPointPrice2 = 0
DO
StillTrue = TRUE
Looker = Looker + 1
BackOffset = SwingLen + Looker
FOR i = 0 to SwingLen
IF StillTrue = TRUE THEN
IF instrument.Low[BackOffSet] > instrument.Low[BackOffSet-i] OR _
instrument.Low[BAckOffSet] > instrument.Low[BackOffSet+i] THEN
StillTrue = FALSE
ENDIF
ENDIF
NEXT
IF StillTrue = TRUE THEN
LowTurningPointPrice1 = instrument.Low[BackOffset]
LowTurningPointDate1 = datetojulian(instrument.Date[BackOffset])
LowTurningPointBar1 = instrument.Bar[BackOffset]
ENDIF
LOOP UNTIL Looker > MaxLookBack OR LowTurningPointPrice1 <> 0
//////////////////////////////////////////////////////////////////////
You may have a fast CPU this take a lot of time to compute.
------
I then had this dream that this could be resolve like this. You create an IPV Series where you just do the following.
You create an IPV Series variable and on you Entry Order you assign its previous day value and you check against the Lowest low of double the period you are looking.
Ex: I want the latest price where I had 4 day with highest Low on each side. So: Dip = 4
LastLowDipPrice = LastLowDipPrice[1] ' My IPV Series variables
'
' Now find the latest Dip Point
'
if instrument.Lowest("Low",Dip*2+1) = instrument.Low[Dip+1] THEN
LastLowDipPRice = instrument.Low[Dip+1]
endif
///////////////////////////
Voila!! You have an IPV Series that carry your latest support price.
If you want to search for a Support where you had 6 day on the left and 3 on the right. Market start to bounce from a retracement type.
You would nead 2 variables MaxDipLength and DipPOint
LeftDipLength=6
RightDipLength = 3
if instrument.Lowest("Low",LeftDipLength+RightDipLength+1) = instrument.Low[RightDipPoint+1] THEN
LastLowDipPRice = instrument.Low[RightDipPoint+1]
endif
////////////////////////
This will compute probably 50 times faster. and obviously you can reverse that to find the resistance point.
//////////////
Here is sample output of the IPV Series with a 5 day Dip point