anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.14k stars 557 forks source link

change the input data order #169

Closed iofirag closed 5 years ago

iofirag commented 5 years ago

First, Love the library! Thanks for all the hard work! my issue is:

Data count less than data required for the strategy HammerPattern Data count less than data required for the strategy HammerPatternUnconfirmed Data count less than data required for the strategy TweezerBottom

Current

current situation is that we need to create input for pattern that need 2 days, and create another for the one with the 3 days, and kind of.

input2Days = {
   open: [ 
               data-of-1-days-back,  // for example 4.12.2019 
               today,                // for example 5.12.2019
   ],
   close: ......
}
input3Days = {
   open: [ 
               data-of-2-days-back,  // for example 3.12.2019
               data-of-1-days-back,  // for example 4.12.2019 
               today,                // for example 5.12.2019
   ],
   close: ......
}

how can i check all the patterns in the same input?

Expected

think to create it more generic way. in that way i will build input as long as max pattern need, when we build it with first value is the latest value (today) and the other one is yesterday, and the third is 2 days back, .... and send it for checking.

for example if i will check the input for 5 last days, every pattern

for example if i gave input

input = {
  open: [ 
             today,                // for example 5.12.2019
             data-of-1-days-back,  // for example 4.12.2019 
             data-of-2-days-back,  // for example 3.12.2019
             data-of-3-days-back,  // for example 2.12.2019
             data-of-4-days-back], // for example 1.12.2019
   ],
   close: ......
}

pattern that need 2 days will take the first #1 and second #2 parameters from the array. pattern that need 3 days will take the first #1 and second #2 and third #3 parameters from the array.

in that way- we can create one input object for all the patterns.

anandanand84 commented 5 years ago

@iofirag It works the way you expect. Did you check this https://github.com/anandanand84/technicalindicators/blob/master/src/candlestick/CandlestickFinder.ts ? If you still face this issue, can you send a sample data?

iofirag commented 5 years ago

yes, i see, https://github.com/anandanand84/technicalindicators/blob/master/src/candlestick/CandlestickFinder.ts#L66 so just for understand, if i set open:[5/12/19(data), 4/12/19(data), 3/12/19(data), and vice versa..] so i dont need to set reversedInput = true ?

(i a little bit confuse about reversedInput field)

anandanand84 commented 5 years ago

oldest data is always last. If you give oldest data first you need to say reversedInput as true

iofirag commented 5 years ago

got it!. thanks 👍