Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. kk7134
    3. Posts
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    K
    • Profile
    • Following 1
    • Followers 0
    • Topics 2
    • Posts 3
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by kk7134

    • Help with FibonacciPivotPoint()

      Hi All

      I want to call FibonacciPivotPoint() method using the High, Low & Close values and use the results in the strategy. I am not sure how to pass the HLC info and get back the calculated values like PP, R1, S1 etc. Any help here is much appreciated

      self.pvData_H = 377.75
      self.pvData_L = 317.05
      self.pvData_C = 334.10
      
      self.Fib = bt.indicators.FibonacciPivotPoint()
      
      
      posted in Indicators/Strategies/Analyzers
      K
      kk7134
    • Help with Sorting the Python List

      Hi All

      I am using optimizer functionality to evaluate the best parameter combination that I can use in my trading strategy. The output from the optimizer for each parameter set (Slow_EMA, Fast_EMA) along with it's value are added to the list and the code for the same is

      val_list = [self.params.sl_maperiod, self.params.ft_maperiod,self.broker.getvalue()]
      print (val_list)

      the first column is Slow_EMA value and the second column is Fast_EMA value and the third column is the cash value that the optimizer generates for the Slow_EMA and Fast_EMA combination. I am providing the output below

      [5, 20, 101416.90550000001]
      [5, 21, 101717.35600000001]
      [5, 22, 101942.15999999999]
      [5, 23, 101938.65450000002]
      [5, 24, 101785.45050000002]
      [5, 25, 102084.91550000002]
      [5, 26, 101634.87550000002]
      [5, 27, 101835.576]
      [5, 28, 101889.99200000001]
      [5, 29, 101906.11300000001]

      I want to sort this output in a descending order based on column 3(Cash Value) such that the record with the highest value gets displayed at the top.

      Please help me here

      posted in Indicators/Strategies/Analyzers
      K
      kk7134
    • RE: How do I set up correct position close logic?

      @bernardlin You have to check whether the position is a Long Position or Short position, before trying to close it. The position object has size property which will be +ve for Long position and -Ve for short position. You have to check for this before trying to close a position

      What it happening in your code is, the position check is being evaluated and since the system does not know whether you are looking to close a long or short position it is simply executing the condition that is being met in the 'Else' block

      Hope it helps

      posted in General Code/Help
      K
      kk7134
    • 1 / 1