Can be used to discourage new trades if the trade direction is against the current gradient direction.
Can be used as an indicator that we are stuck in a sideways market (gradient is fairly flat) and perhaps not a good time to open new trades
To see if this works, I developed a new oscillator that shows a histogram of the gradient of the curves. There was some difficulty in calculating the angle. Calculating an angle needs to perform the math.atan(opp/adj) however adj is a measure in time. Therefore, we can make the adj value anything we like. This is the same as changing the chart scaling, or zooming in and out, and watching the steepness of the curve change. Not only that, how many bars back do we go?
To solve this problem I did some experimenting. I defined something called GradientPeriods which is the number of bars to go back. Looking at the 1H chart for AUDJPY, over a 2-3 day period, showed me some gradients I would consider steep, and others not steep. This lead me to come up with a factor of 0.115 that can be used to multiply the GradientPeriods. This produced values that looked pretty good.
One other thing to keep in mind is the tan/atan functions operate in radians so this needs to be converted too.
Illustration of the first point.
The effectiveness of this is immediately seen by looking at the journal entry for June 10th. By looking at the screenshot it is clear that the new trade would not have been opened if it cross checked against the gradient. However, this needs to be tested as this depends on the number of periods used.
Looking at the image below, we can see the top histogram with a GradientPeriods of 10, and the bottom histogram with a GradientPeriods of 1. The lower one immediately responds which produces higher values (values at 23:00 are Upper-5 and Lower-25), but also immediately reports the direction. The upper one is much smoother however.
Need to do some testing to see what GradientPeriods would be better for preventing the loss trades in this scenario.
Illustration of the second point.
Backtesting Omar (6,19) shows two loss trades on 21st of May 2013 and 23rd of May 2013. Looking at what the gradient of the slow curve was at these times, it was very low, less than 5 degrees using a GradientPeriod of 10.
By optimizing, it should be possible to find a gradient value which can be used as a floor to prevent new trades from opening unless the gradient is steeper. Hopefully this can prevent loss trades in a sideways market.