This system measures the per bar percent change from the open 2 bars ago, turns it into an angle and runs it through a sine function. A cross above 0.02 buys and a cross below -0.02 sells short. It has not been backtested yet.
| positionSize Contracts per trade | 1 |
| anglePeriod Bars the price change is measured over | 2 |
| angleThreshold Entry level for the angle reading | 0.02 |
| takeProfitPoints Profit target in points | 275 |
| stopLossPoints Protective stop in points | 350 |
The code
Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.
// ============================================================ // Price Angle Trend // ProRealAlgos Strategy Library | prorealalgos.com // Type: Momentum // Direction: Long & short // Timeframe tested: Not yet tested // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false // --- Parameters --- positionSize = 1 // contracts per trade anglePeriod = 2 // bars the price change is measured over angleThreshold = 0.02 // entry level for the angle reading takeProfitPoints = 275 // profit target in points stopLossPoints = 350 // protective stop in points // --- Indicators --- // Percent change per bar, turned into an angle and scaled with sine. priceAngle = SIN(ATAN((close - open[anglePeriod]) / open[anglePeriod] * 100 / anglePeriod))
16 more lines: the entry and exit rules.
Read this first
Questions
The code is written for ProOrder, but it is not compile checked or tested. Backtest it on your chosen market first.
Nothing yet. The point based stop and target are sized for an index like the DAX, so other markets would need new values.
With 1 contract the stop is 350 points plus spread. There is no drawdown figure until a backtest is run.
Converting the change to an angle and taking the sine squeezes large moves into a bounded range, so one threshold of 0.02 can work across calm and fast periods.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.