Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 3/7/2014(UTC) Posts: 17
Thanks: 6 times
|
Hi, I am trying to code swing points both high and low. Following are the conditions:
1) Swing Point High - high of current bar must be highest of next 6 bars. 2) Swing Point Low - low of current bar must be lowest of next 6 bars.
I have done the coding for the above. following are the coding:
1) Swing Point High H>Ref(H,+1) AND H>Ref(H,+2) AND H>Ref(H,+3) AND H>Ref(H,+4) AND H>Ref(H,+5) AND H>Ref(H,+6)
2) Swing Point Low L<Ref(L,+1) AND L<Ref(L,+2) AND L<Ref(L,+3) AND L<Ref(L,+4) AND L<Ref(L,+5) AND L<Ref(L,+6)
The above 2 codes are fulfilling the conditions. BUT i want one more condition to be satisfied. If any or all next six bars are also SPH/SPL it should not be shown on chart.
Attached is the chart for reference. Kindly help.
Regards, K
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
I'm not really certain of what your trying to achieve, but be very aware of how much looking into the future you allow in your trading. Try this: Code:
sph:=H>Ref(H,+1) AND H>Ref(H,+2) AND H>Ref(H,+3) AND H>Ref(H,+4) AND H>Ref(H,+5) AND H>Ref(H,+6);
sph:=sph AND Alert(sph=0,2);
{plot}
sph AND Ref(BarsSince(sph),-1)>6;
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 3/7/2014(UTC) Posts: 17
Thanks: 6 times
|
wabbit wrote:I'm not really certain of what your trying to achieve, but be very aware of how much looking into the future you allow in your trading. Try this: Code:
sph:=H>Ref(H,+1) AND H>Ref(H,+2) AND H>Ref(H,+3) AND H>Ref(H,+4) AND H>Ref(H,+5) AND H>Ref(H,+6);
sph:=sph AND Alert(sph=0,2);
{plot}
sph AND Ref(BarsSince(sph),-1)>6;
Hi Wabbit,
Thanks for prompt reply. I am actually trying to find out the swing points for support and resistance using the conditions. Its a lagging tool.
Thanks for the code. I have copied it in expert advisor and attached the same on the chart. Its working. BUT its not highlighting all the bars which is also fulfilling the formula condition.
Attached is the 60 bars EOD chart for your reference arrows are showing the bars fulfilling the condition as per the code provided by you. But there are bars on the chart which should also show the down arrow as all of them are fulfilling the condition.
Request you to please help.
Regards, K
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Ah... ok, I think I understand now your "time/bar limits"? How's this? Code:
sph:=H>Ref(H,+1) AND H>Ref(H,+2) AND H>Ref(H,+3) AND H>Ref(H,+4) AND H>Ref(H,+5) AND H>Ref(H,+6);
{plot}
hi:=If(PREV=0,sph,
If(BarsSince(PREV=0)<6,1,0));
{plot}
hi AND Alert(hi=0,2);
[edit] I'm pretty sure the code meets your definition, but I think your definition needs some further refinement, as you will see when you plot this during a downtrend. I don't think you can simply say to ignore repetitive signals which occur within 6 bars of a previous signal, because as soon as the period is over, the code will trigger a new event, which will not help you to identify resistance/support levels.
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 3/7/2014(UTC) Posts: 17
Thanks: 6 times
|
Hi Wabbit,
Thanks a ton!
The code is working great both in the down and up trend.
There is only one problem (which I think I can manage :) ). If the left most bar is SPH it is now showing as per the code. I have attached the chart for the same for your reference. I have changed the condition a bit. I have removed the H+6 and L+6 from the condition.
Basically I am trying to find the trend as well as support and resistance from using this swing points or fractals. If you see the chart you will see clear hh and hl in the uptrend on the chart as per the conditions. System is trend trading, its still in work in progress.
Thanks once again for helping me out.
Reagrds, K
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 12/7/2013(UTC) Posts: 23
Thanks: 1 times
|
hi wabbit
you code is working when i past this indicator >new but when overlay with chart just show line graph not like text high lite in chart bar SPL and SPH what should i do for correct ?
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/10/2017(UTC) Posts: 1
|
how to take trade through swing point ? please advise.
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.