- UID
- 2
- 积分
- 2893117
- 威望
- 1396590 布
- 龙e币
- 1496527 刀
- 在线时间
- 13326 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-12-26
|
his indictor decides the "binary trend" which means it converts it to a number. Thus uptrend =1 downtrend =-1 and the initial value is assigned as 0.
Code tips
If you plot the 80 period moving average and the 12 period moving average on the chart you can check the trend indicator is working.
Using end else statements to reduce code length. EG above assumes that if the trend is not 1 then it must be -1.
Code tricks to try
If you try using another method to assign the trend is up or down and replace the code with your idea. EG. You use the stochastic oscillator with above 50 being uptrend and below 50 being down trend.
The equal to 50 can be caught by saying this. If stochastic is >=50 then count as uptrend ( psuedo code) |
|