Firetron’s FractionMiddle

2 76 Views No Comments 3 months ago
  • Finds the middle value of a fractional portion of a table of values.

    Custom Command Dependencies:
    Firetron’s FractionGrab
    Firetron’s Median

    Test code:

    if not Load('done', false) then
    
      local list = Grab(ClosePrices(), 0, 12)
    
      Log(' ')
      Log(list)
      Log('Unsorted List:')
      Log(' ')
    
      Log(ArraySort(list))
      Log('Sorted List:')
      Log(' ')
    
      local median = CC_FractionMiddle('median', list, 3, 4)
    
      Log(median)
      Log('Median Value of 3rd portion of 4:')
      Log(' ')
    
      local average = CC_FractionMiddle('average', list, 3, 3)
    
      Log(average)
      Log('Average Value of 3rd portion of 3:')
      Log(' ')
    
      median = CC_FractionMiddle('median', list, 1, 3)
    
      Log(median)
      Log('Median Value of 1st portion of 3:')
      Log(' ')
    
      Save('done', true)
    
    end
    • This topic was modified 3 months, 1 week ago by Firetron. Reason: Made all parameters optional
    • This topic was modified 3 months, 1 week ago by Firetron. Reason: Extracted FractionGrab to another command
    HaasScript Code
    Sign in or Register to view
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free