Australian (ASX) Stock Market Forum

Mechanical Swing Trading

Joined
26 October 2008
Posts
2,931
Reactions
7
Starting a new thread on this topic to not clutter the other thread:


Im interested in the formula for identifying swing trading in a system
You wouldnt happen to be able to post it would you?
Neer been able to find one.That Works.

Here's a signalling system I wrote, it uses Ichimoku for S/R zone (Ichimoku lines aren't the same as a moving average, look them up if you don't know what they are).

Not every arrow is a signal. You take arrows that line up with S/R (previous lows and highs). For longs, signals around previous lows are more significant though you can trade RbS signals. For shorts, signals around previous highs are more significant, though you can trade SbR signals. For the RbS/SbR it is probably best to adjust the position for volatility or trade half size. You can enter long using stops at the high or limits at the low depending on your belief in how the market works (converse for shorts).

The formula is based on one which is widely known, even published on the internet, I think if you googled "swing trading" it would be in the top 3 hits. Designed for stocks but whatever. I just use Ichimoku instead of MAs.

Here are clean 4 hour charts with the signalling software enabled for the forex majors. Sorry about the EURUSD chart being more zoomed in, I've been messing with the tick database and managed to break it somehow so zoomed into where the signals are accurate.
uj.jpguc.jpg
gu.jpgeu.jpg
eu2.jpg

The code is raw, it isn't perfect. It misses a lot of trades I would have taken, but it does give you an idea.

I am posting this code only for illustration and discussion purposes. It is free of charge, assuming you don't rip it off and try to sell it or something. If you like it, and run a hedge fund needing a compsci geek, hire me! ;):p:

Code:
   while( i >= 0 )
   {
      double ts = iIchimoku(NULL,0,9,26,52,MODE_TENKANSEN,i);
      double ks = iIchimoku(NULL,0,9,26,52,MODE_KIJUNSEN,i);
      double sa = iIchimoku(NULL,0,9,26,52,MODE_SENKOUSPANA,i);
      double sb = iIchimoku(NULL,0,9,26,52,MODE_SENKOUSPANB,i);
      double wpr = iWPR(NULL,0,6,i+1);      
      double wpr2 = iWPR(NULL,0,6,i+2);
      //SHORT
      if (ts < ks && (High[i] < High[i+1] || (High[i] > High[i+1] && Low[i] < Low[i+1] && Close[i] < Close[i+1])) && High[i+1] > High[i+2] && Close[i+1] < ks && Close[i+1] > ts && Close[i] < sa && Close[i] < sb && (wpr > - 20 || wpr2 > -20)){
         hi[i] = High[i] + BasePips(DistanceFromCandle) * Point;
      }
      else
      {
         hi[i] = 0;
      }      
       //LONG 
      if (ts > ks && (Low[i] > Low[i+1] || (Low[i] < Low[i+1] && High[i] > High[i+1] && Close[i] > Close[i+1])) && Low[i+1] < Low[i+2] && Close[i+1] > ks && Close[i+1] < ts && Close[i] > sa && Close[i] > sb && (wpr < -80 || wpr2 < -80))
      {
         lo[i] = Low[i] - BasePips(DistanceFromCandle) * Point;
      }
      else
      {
         lo[i] = 0;
      }
 
Great work sinner I'm impressed with your coding ability.
I'm hoping to become an expert on coding myself eventually.
 
Thanks waza, I'm wondering why tech hasn't replied yet, I only posted it for his benefit?

Sorry I have had a look and you have had me racing to my library to brush up on Ichimoku.

I note that the code has imbedded Ichimoku code (.TENKANSEN etc)
Without it you cant run the code through I presume amibroker.
I have the code for metastock but have never really studied the analysis method.

So I cant see how at this point until I educate myself how it works as a swing trading method---but "Presume" not as a conventional pivot high/low method would be traded.(The presumption is from the arrows on your charts).

Off to listen to David Suzuki tonight so may not answer until tommorow---but I'm interested in persuing this further Sinner.
 
Sorry I have had a look and you have had me racing to my library to brush up on Ichimoku.

I note that the code has imbedded Ichimoku code (.TENKANSEN etc)
Without it you cant run the code through I presume amibroker.
I have the code for metastock but have never really studied the analysis method.

The code is written for Metatrader (MT4).

Quick Ichimoku redux:
Tenkan-sen: (Highest high of the last 9 periods + Lowest low of the last 9 periods)/2
Kijun-sen: (Highest high of the last 26 periods + Lowest low of the last 26 periods)/2
Kumo:
- Senkou A: (TS+KS)/2 shifted into the future 26 periods
- Senkou B: (Highest high of the last 52 periods + Lowest low of the last 52 periods)/2

Essentially a bunch of dynamic 50% lines.

So I cant see how at this point until I educate myself how it works as a swing trading method---but "Presume" not as a conventional pivot high/low method would be traded.(The presumption is from the arrows on your charts).

I just use it as a generalised pullback zone. You could qualify it as:

"Wait for price to pullback below 50% of the 9 bar range, but above 50% of the 26 bar range, supported by the longer term trend as represented by the kumo".

Williams % R in this case, is just a lazy code proxy for a 6 bar pullback into the above qualified zone. I use 6 for forex, but only 3 bar pullback for most other instruments. This is the correct technical use for %R indicator.

Then we just wait for a swing point low pattern to establish itself using higher low->lower low->higher low OR an outside bar proceeding after a higher low->lower low as the criteria.
swpl.png

So:

Uptrend -> 6 bar pullback into "pullback zone" -> swing point low -> long after checking the S/R at the swing point low.

The indicator operates on the assumption you are only trading at the close/open of a new bar.

Off to listen to David Suzuki tonight so may not answer until tommorow---but I'm interested in persuing this further Sinner.

Look forward to your thoughts.
 
Top