I am working on a Fibonacci trading system which I plan to upload soon. Maybe you are interested in an optimizable function that I am going to include (see code below).
This function
a) provides exact Fibonacci retracement and extension levels
b) allows optimization regarding different Fibonacci levels, for instance:
Optimize("fibo_index", 0, 7, 1);
var = fibonacci(fibo_index);
will result in var = {0, 21.4, 23.6, 38.2, 50, 61.8, 76.4, 78.6}
Please note:
You can modify elements of the fibo array. As elements will be ordered, they might not be in the original sequence.
Elements of the fibo array are Zero-based.
fibonacci(-1) returns the number of elements in the fibo array.
Any suggestions? Just let me know.
// ----------------------------------- C# - fibonacci function ------------------------------------------
// Define a numeric parameter i for this function, which is the index, currently from 0 to 17, where 0 = 0%, 8 = 10 % and 17 = 423,6%
// Set function to return a numeric array
double phi = (1 + Math.Sqrt(5)) / 2; // http://en.wikipedia.org/wiki/Golden_ratio
double[] fibo = {
0, // 0 %
1 - 1 / Math.Sqrt(phi), // 21.4%
2 * phi - 3, // 23.6%
2 - phi, // 38.2%
0.5, // 50 %
phi - 1, // 61.8%
4 - 2 * phi, // 76.4%
1 / Math.Sqrt(phi), // 78.6%
1, // 100 %
2 * phi - 2, // 123.6%
Math.Sqrt(phi), // 127.2%
3 - phi, // 138.2%
1.5, // 150 %
phi, // 161.8%
5 - 2 * phi, // 176.4%
2, // 200 %
1 + phi, // 261.8%
2 * phi + 1, // 423.6%
};
Array.Sort(fibo);
i[0] = Math.Floor(i[0]);
if (i[0] == -1) result = fibo.Length;
if (i[0] >= 0) result = 100 * fibo[(int)i[0]];
I am presently working on a Money Management Script that will be necessary for the fibonacci trading system and will allow stop and profit target setting at absolute price levels.
If for instance you want to enter a position at 76.4 and want to place your stop loss at 61.8 and set your profit target at 100, then you can of course define a profit stop as (100-76.4 = 23.6) and a stop loss as (76.4-61.8 = 14.6). But they will not be fix as per standard. If you enter at 75 (e.g. due to an opening gap), your stop loss will be at 60.4 and profit stop at 98.6. The dilemma being, that on the signal date you don't know the final entry price, and on the entry date you don't know your original price limit.
But ... there will be a solution posted soon.
Also the swing point function http://www.quantshare.com/item-1121-swing-point-function-sp will play a big role in identifying the fibonacci turning points. I consider this one as the core of the system. So if you want, have a look at this code meanwhile and let me know about any questions or suggestions.
Few months ago, I have create a basic Fibonacci retracement indicator which tells you whether a stock is near a retracement level or not.
The levels are calculated based on the previous N-bar high and low. Fibonacci Trading with the Retracement Levels/Ratios
Using the money management script is the only way to get the exact stop and profit levels.
Today I have uploaded an MM script "Stop Mgmt" that includes the ability to use exact stop levels. Please try it and let me know about any questions, issues, suggestions ...
I have uploaded the Fibonacci Trading System today.
Enjoy and let me know about any questions, remarks, suggestions ...
I would also appreciate if you would report about the results of your optimizations (performance, markets, optimized parameters, ...)
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.