龙听期货论坛's Archiver

C
+
+


 微信: QQ:

龙听 发表于 2020-11-28 07:45

Simple binary trend indicator

**** Hidden Message *****

龙听 发表于 2020-11-28 07:46

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)

阿土伯 发表于 2020-12-3 16:05

学习

页: [1]