giving support and resistance another chance (bouncing)
I have been thinking a bit, after stopping my compulsive posting here. By the way, I will post less in the future. I will try to keep it down to a few posts per month, all related to trading.
In these two weeks, I might have come up with a good idea that I should develop in the future, in terms of automating it: support and resistance, in terms of bouncing on it (not breakouts).
But it will be very hard to automate and for now I will just monitor it and briefly explain it here.
See attachment:
View attachment links.zip
You will find 13 links to futuresource.com charts of the 13 futures which my automated systems are trading:
6 currencies
2 stock indexes
2 bonds
gold, oil, natural gas
All the futuresource.com charts are set up on a daily timeframe.
I have placed in a separate folder the six futures that are approaching a support/resistance level.
My theory is that support and resistance on a daily basis do work. It's not a revolutionary idea, it's not new, and it's very simple, but if it works, it will be very good for me.
As I mentioned, it will be hard to automate it, but the idea in itself is very powerful for me, because I already know all the other edges (time of the day, and overbought/oversold conditions) and support and resistance was the last major edge i was missing.
For now I am referring to just horizontal support and resistance lines and not diagonal lines, but I am not ruling out to focus on those as well in the future (even harder to automate).
This is all I had to say (the rest will keep evolving in my mind), but I will quote a clear example of what I am referring to. Here's the daily AUD/USD chart:
You see, we have many things that tell us there will most likely be a powerful reversal:
1) the forex markets don't just keep rising forever, but zigzag much more and move in ranges
2) the dollar is highly oversold
3) the AUD is approaching resistance
If you add to this the time edge (what time of the day is it?) and the correlation with other currencies, you pretty much can forecast a reversal with great accuracy.
What I am missing is the fact that I have not backtested this, so not only is it impossible to automate, but I don't even know if what makes so much sense does actually work, in that I have neither traded it nor backtested it.
How would i go about backtesting and therefore coding this?
It will be my concern of the next few weeks.
What is resistance?
It is the High of let's say the last year, but that's not enough, because there could be a higher high one day before, which would totally invalidate it.
So it is ok to use a set period in the past (pointless to go back 30 years).
But in easylanguage (the first part of my job will be coding it on tradestation) we have to use the concept of "swing high":
...Swing High occurs when the PRICE of a bar is higher than the PRICE on the preceding bar(s), and at least as high as the same PRICE on the bar(s) that follow it...
That's right: this is because we want to make sure that it was the HIGH in terms of days following it, but also that it was the HIGH in terms of days preceding it. Then it could qualify as resistance.
Doing this by eye is very easy (but also there's a danger of making mistakes). Coding this is not easy at all. Automating is another problem (but easier since you've already defined it univocally when coding it for backtesting).
[...]
After some efforts, I am giving up on this, because it is just too much work to face right now. I will have to resume some other time and maybe some other way, too. However, I am pretty certain this is a valuable edge (support and resistance). It would be great to automate it because it takes a lot of patience to wait for S/R to be reached and it would be traded best as an automated system. But this can't be done unless I first test it, and I can't do this unless I first figure out how the SwingHigh function works.
Ok, I just found the right links, one for the function:
http://www.traderslaboratory.com/forums/f56/swinghigh-swinglow-easylanguage-functions-6284.html
and one for the indicator (I want to draw it to see what's going on):
http://www.elitetrader.com/vb/showthread.php?threadid=107989
This is still very hard. It reminds me of the systems on pivots (R1, S1, Pivot point), which I did manage to code but that did not prove profitable.
The problem is that the concept of SwingHigh as simple as it may be, in my little room, with all the work and worries, with all the noise around me, at the moment... defeats my brain. I cannot figure out how this simple code works and all its implications. I cannot focus enough to do it.
I am going to write to adamus to see if he can help out. I am stuck.
SwingHigh( Instance, Price, Strength, Length )
The indicator did not come out right.
I started working on the easylanguage code nonetheless and I am getting there, little by little, even though, without indicator, I am almost moving in the dark.
I fail to grasp the concept of that SwingHigh formula. There's just too many interruptions here in Rome: neighbours, relatives, sounds sounds sounds. I can't focus.
Here's what I came up with. Just doing in-sample for now, because I am far from coming up with the final formula.
Code:
Inputs: test(0), test2(0), test3(0);
Vars: resistance(0), support(0);
resistance = SwingHigh(1,high,test2,test3);
support = SwingLow(1,low,test2,test3);
If marketposition = 0 and low < support Then Buy This Bar;
If marketposition <> 0 and time >= 1600 Then ExitLong This Bar;
If marketposition = 0 and high > resistance Then sell This Bar;
If marketposition <> 0 and time >= 1600 Then Exitshort This Bar;
At the moment I am running an optimization on the two variables of the SwingHigh and SwingLow formulas, even though I don't completely understand it (due to noise disrupting my thinking).
Through the optimizations I came up with nothing because I can't properly visualize what it's doing and I can't visualize it in my mind, because I am dead tired from work and bothered by all the noises around me.
However I might be developing a side formula for a new system.
Indeed the method still somehow works, but I might as well bet on a bounce off today's high and low... setting aside for the moment the other system.
Nope, nothing at all.
Nothing worked.
I will still have to go back and figure out the swinghigh and swinglow functions, sooner or later, and find a way to code support and resistance.
I am quite sure that they work, so I really need to find a way to backtest them to know exactly how to trade them.
Here's a snapshot of the current problems I am having with the easylanguage SwingHigh formula:
This thread shows the complexity of what I am trying to achieve:
http://www.trade2win.com/boards/mechanical-systems-trading/85466-easylanguage-question.html
This is too complex for my capabilities.
For example, even tradestation makes available this signal, "TrendLines Automatic Long Entries". But it has too many variables and I get lost into that code. Let alone automating the whole thing after I am done backtesting.
Let's go back to basics and resume from there. Let's forget SwingHigh for the moment.
Here's, once again, the daily AUD/USD chart:
What do I want to know? I want to go short if we get near the high of the whole chart, which means the high of the last year. I don't care what happens before.
This is going to be achieved with this (simpler) function:
High>Highest(High,200)[1]
The system would look something like this:
If marketposition = 0 and High>Highest(High,100)[1] Then sell This Bar;
If marketposition <> 0 and time >= 1600 Then Exitshort This Bar;
Now this is much clearer.
But there's a problem. That value is only good if it's lasted for a while, so once again we need the SwingHigh function, because it verifies that the High has lasted for a while. Except we want that High to be the highest one and I still don't know how to do it.
Now, what would happen if I added the SwingHigh function to the Highest function?
If marketposition = 0 and High>Highest(High,1000)[1] and High>swinghigh(1,High,200,1000) Then sell This Bar;
If marketposition <> 0 and time >= 1600 Then Exitshort This Bar;
Nothing changes. What is worse is that I still don't fully comprehend what I am doing with that function.
So back to basics again and I will use "highestbar" which is the number of bars ago the highest value was recorded.
If marketposition = 0 and High>Highest(High,1000)[1] and HighestBar(High,1000)[1] > 200 Then sell This Bar;
If marketposition <> 0 and time >= 1600 Then Exitshort This Bar;
This makes sure that the highest high lasted at least for 200 bars (two days because I am using 15 minute bars right now).
Ok, I am getting there.
This code triggers a trade if price ever goes higher than the highest peak of the last year, and if that peak has lasted at least 10 days (every 100 bars is about one day):
If marketposition = 0 and High>Highest(High,20000)[1] and HighestBar(High,20000)[1] > 1000 Then sell This Bar;
If marketposition <> 0 and time >= 1600 Then Exitshort This Bar;
Except that it makes no money.
Instead I found this system which almost always makes money, and even though it is a bit far from what I wanted to achieve, I might come up with something good ultimately from all this reasoning:
If marketposition = 0 and High>Highest(High,2000)[1] and HighestBar(High,2000)[1] > 100 and time > 1100 Then sell This Bar;
If marketposition <> 0 and time >= 1600 Then Exitshort This Bar;
If marketposition = 0 and low<lowest(low,2000)[1] and lowestBar(low,2000)[1] > 100 and time > 1100 Then buy This Bar;
If marketposition <> 0 and time >= 1600 Then Exitlong This Bar;
How's a profit factor of 20? Good enough?
This system basically goes long/short when, after 5 PM CET, this month's low/high is surpassed.
This is even better and closer to what I had in mind:
If marketposition = 0 and low<lowest(low,2000)[1] and lowestBar(low,2000)[1] > 100 and time > 1100 Then begin
buy This Bar;
entry_date = datetojulian(date);
end;
If marketposition <> 0 and datetojulian(date) >= entry_date + 15 Then Exitlong This Bar;
If marketposition = 0 and High>Highest(High,2000)[1] and HighestBar(High,2000)[1] > 100 and time > 1100 Then begin
sell This Bar;
entry_date = datetojulian(date);
end;
If marketposition <> 0 and datetojulian(date) >= entry_date + 15 Then Exitshort This Bar;
Very few trades but a profit factor of almost 6. And I know how to automate it.
I will stop posting this code from here on, for secrecy purposes. I'm getting too far in my creation. From here on I will keep it to myself.