lib/cotcube-level/tritangulate.rb in cotcube-level-0.3.2 vs lib/cotcube-level/tritangulate.rb in cotcube-level-0.3.3

- old
+ new

@@ -17,10 +17,11 @@ cached: true, # allow loading of cached results interval: , # interval (currently) is one of %i[ daily continuous halfs ] swap_type: nil, # if not given, a warning is printed and swaps won't be saved or loaded with_flaws: 0, # the maximum amount of consecutive bars that would actually break the current swap # should be set to 0 for dailies and I suggest no more than 3 for intraday + manual: false, # some triggers must be set differently when manual entry is used deviation: 2 # the maximum shift of :x-values of found members ) raise ArgumentError, "'0 < max < 90, but got '#{max}'" unless max.is_a? Numeric and 0 < max and max <= 90 raise ArgumentError, 'need :side either :upper or :lower for dots' unless [:upper, :lower].include? side @@ -68,12 +69,14 @@ }. reject{|b| b.nil? or b[:datetime] < first[:datetime] or b[:x] < 0 or b[:y].nil?}[range] # abs_peak is the absolute high / low of the base. the shearing operation ends there, # but results might be influenced when abs_peak becomes affected by :with_flaws - abs_peak = base.send(high ? :max_by : :min_by){|x| x[high ? :high : :low] }[:datetime] - base.reject!{|x| x[:datetime] < abs_peak} + unless manual + abs_peak = base.send(high ? :max_by : :min_by){|x| x[high ? :high : :low] }[:datetime] + base.reject!{|x| x[:datetime] < abs_peak} + end ###########################################################################################################################z # only if (and only if) the range portion above change the underlying base # the offset has to be fixed for :x and :y @@ -153,10 +156,10 @@ # the return condition is if no new members are found in slope # except lowest members are neighbours, what (recursively) causes re-run until the # first member is solitary if new_members.empty? mem_sorted=members.sort - if mem_sorted[1] == mem_sorted[0] + 1 + if mem_sorted[1] == mem_sorted[0] + 1 and not manual b2 = b[mem_sorted[1]..mem_sorted[-1]].map{|x| x.dup; x[:dx] = nil; x} puts 'starting recursive rerun'.light_red if debug alternative_slope = get_slope.call(b2) alternative = alternative_slope[:members].map{|bar| bar[:i]} # the alternative won't be used if it misses out a member that would have