A PitchFork Price function to return price at any point and deviation from median available for general use
Hi All,
I recently had a requirement to obtain prices from a pitchfork, and more so trend lines running parallel in between the forks at x% deviations. Realising this is no straight forward task due to no GetValueByShift for pitchforks and having searched a fair bit for a function that calculates the pitchforks manually without much luck (apologies if it does exist),
No as far as I'm aware it doesn't work, besides which it wouldn't return the values of deviations of the normal lines
The good thread with real examples of trading -
----------------
Trading the Andrews Pitchfork with Max
This thread is educational and the aim is to educate thread members in the correct way to manually take pips from the market. It will be suited to all grade and types of trader.
· It will suit the busy professional who only has 15 minutes before breakfast to place his/her trade before leaving for the office;
· It will suit the busy mother/father who has to be up and down feeding the baby and cleaning the house;
· It will suit the trader who has the commitment but has never been shown the direction;
· It will suit those who are tired of getting their account blown by service providers;
· it will suit those who are tired of blowing their own account.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
UPDATE - Apologies I have now found a bug in the deviation line calculation. In the process of rectifying it now. I'll repost the function when it's fixed
UPDATE - Looks to be working correctly now, had incorrect variable as start point for the deviation line.
Hi All,
I recently had a requirement to obtain prices from a pitchfork, and more so trend lines running parallel in between the forks at x% deviations. Realising this is no straight forward task due to no GetValueByShift for pitchforks and having searched a fair bit for a function that calculates the pitchforks manually without much luck (apologies if it does exist), I thought I would set about building a function that could do it for me without the requirement for drawing trend lines and using GetValueByShift i.e pure calculation of the price. As I needed it for an EA, not having to draw the trend lines is a much better outcome in my opinion for initial back testing. Plus for me I would prefer to be able to keep all the values and calculations in my code than rely on reading from objects.
Anyway once I finished it I thought I'd publish it as it's something I've had trouble finding for a while. I haven't been coding mt4 for long and always found lots of useful code from other people to help me learn so nice to be able to contribute something back. Apologies if there are any bugs, I haven't done extensive testing with it, but so far haven't had an issues with how I've been using it.
Usage:
t_1 = Time1 of Fork (this has to be the time of the anchor point of the fork)
p_1 = Price1 of fork (again price of the anchor point)
t_2, t_3, p_2, p_3 = These are the other prices and times. It shouldn't really matter which way round you put these in. I have built it so it will find the correct point to use for the calculations (not fully tested though)
bar = the bar number back from 0 bar you want to get the price from (0=now)
deviation = percentage above / below median to use as reference line eg 1 would be the top line of the fork, -1 would be the bottom. -0.25 would be a trend line running parallel to median 25% between median and bottom of fork. -1.25 would be 25% past the bottom of the fork etc etc
drawDeviation = draws a trendline for the deviation line
drawLines = draws a vline and hline to mark a cross hair for the price
drawFork = draws a standard pitchfork object using the price/time values parsed
That's about it, happy to take any feedback or provide any assistance.
Cheers
fridayStreet