龙听期货论坛's Archiver

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

Simple length adjusting algorithm

**** Hidden Message *****

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

This is the first stage of making an algorithm to control length applied to an indicator.

You can see that if you plot this indicator in subgraph 2 it ranges between 50 and 10 which are the max and min lengths allowed. ( But these are adjustable inputs )

If the price is making a new high or low for the basic length period it will slow down by 1 length increment for each bar that the condition is true.

If the price not making a new high or low for the same period it will reduce length by 0.5 length increment for each bar the condition is true.

Code tricks to try

If you try changing the values of the -1 and the 0.5 to larger or smaller amounts you can tune it to suit your requirements.

Below I will show you how to build this code into a length changing indicator.

页: [1]