Backtrader Community

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

    Akash Saxena

    @Akash Saxena

    0
    Reputation
    101
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Akash Saxena Unfollow Follow

    Latest posts made by Akash Saxena

    • RE: Iterate between __init__ and next ?

      thanks for this idea !
      yes it can be done, but it takes more time and effort as i have to test my code for the EMAs and other indicators that i use.

      i finally used a strategy to do the above flowchart for EMA line of a particular period. then used optstrategy to iterate over the EMA periods.
      Not exactly what i started to do, but it gets my job done.

      thanks for reaching out with help !

      posted in General Code/Help
      Akash Saxena
      Akash Saxena
    • RE: Iterate between __init__ and next ?

      :-) well, thats right - indeed i'm new to Python as well !
      i had thought of creating lots of EMAs upfront ... but wondered there must be a better way to achieve the goal. till then, i'll implement with lots of EMAs.
      thanks a lot !

      posted in General Code/Help
      Akash Saxena
      Akash Saxena
    • Iterate between __init__ and next ?

      Hi all,
      i'm new to this platform, and am stuck implementing following part of a strategy. i have experimented quite a few things, and read the online help available, but its not working out. any help is welcome !

      Strategy algorithm snippet : (fixed data feed size being used : 1000 periods)

      1. start with an EMA (say, EMA of 200 periods)
      2. generate the EMA line
      3. generate the EMA crossings w.r.t. datas.close
      4. count number of crossings created in 3)
      5. if count is < 10
        5a) decrease EMA period by 1
        5b) goto step 2)
        else
        5c) print out final EMA period and use it for rest of the strategy.

      While implementing above, i create EMA of x period in __init__ of strategy, something like:

      self.current_ema = bt.indicators.ExponentialMovingAverage(self.datas[0].close, period=self.emasize)
      

      i can generate the crossings line in 3) either in __init__ (line processing) or in next (element processing)

      however, the count of crossings can be generated only in next (or so i believe !)

      The problem is, once i generate the count and reach 5b), how do i create the next EMA in 2) ? the control flow wont go back to __init__ for creating a new indicator.

      any ideas/ help welcome !

      posted in General Code/Help
      Akash Saxena
      Akash Saxena