NexusFi: Find Your Edge


Home Menu

 





pandas df.diff() func


Discussion in Platforms and Indicators

Updated
    1. trending_up 1,473 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 StickRustler 
Melbourne, FL
 
Experience: Advanced
Platform: NinjaTrader, ThinkOrSwim
Trading: Futures, Options, Stocks
Posts: 19 since Jul 2020
Thanks Given: 4
Thanks Received: 2

Not elite, so can't post to the 'Python, Pandas...' forum.

I'm attempting to translate the DonovanWall Range Filter (AKA Vumanchu Swing Free) from Python into Java for MotiveWave.

Have no experience in pandas (some in Python).

Here's the func I'm working on

 
Code
def range_size(df: pd.DataFrame, range_period: float, range_multiplier: int):
    wper = range_period * 2 - 1
    # last candle is last index, not 0
    average_range = ta.ema(df.diff().abs(), range_period)
    AC = ta.ema(average_range, wper) * range_multiplier
    return AC
I'm assuming the df.diff() func is taking a data series, calculating diff between each bar and it's previous bar (bar-1), then returning a transformed data series with the results.

Am I correct in this assumption? If so, in MW I'll have to write loops to cycle thru MW's series and preform these diff calculations manually, then create a new series with the results.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My Rant with AMP Futures
Trading Reviews and Vendors
Bitcoin’s 2022 low, 2025 high and 2026 low so far arou …
Cryptocurrency
[WTS] ATAS Lifetime ULTRA license – EU buyers only – …
Platforms and Indicators
No book, only a stair: journaling fills where price move …
Cryptocurrency
Building a free browser DOM/SMC simulator - need some ad …
Platforms and Indicators
 
  #2 (permalink)
 
sam028's Avatar
 sam028 
Site Administrator
 
Posts: 3,779 since Jun 2009
Thanks Given: 3,840
Thanks Received: 4,709


StickRustler View Post
Not elite, so can't post to the 'Python, Pandas...' forum.

I'm attempting to translate the DonovanWall Range Filter (AKA Vumanchu Swing Free) from Python into Java for MotiveWave.

Have no experience in pandas (some in Python).

Here's the func I'm working on

 
Code
def range_size(df: pd.DataFrame, range_period: float, range_multiplier: int):
    wper = range_period * 2 - 1
    # last candle is last index, not 0
    average_range = ta.ema(df.diff().abs(), range_period)
    AC = ta.ema(average_range, wper) * range_multiplier
    return AC
I'm assuming the df.diff() func is taking a data series, calculating diff between each bar and it's previous bar (bar-1), then returning a transformed data series with the results.

Am I correct in this assumption? If so, in MW I'll have to write loops to cycle thru MW's series and preform these diff calculations manually, then create a new series with the results.

Correct, it basically adds a new column in your dataframe.


Success requires no deodorant! (Sun Tzu)
Reply With Quote
Thanked by:
  #3 (permalink)
 StickRustler 
Melbourne, FL
 
Experience: Advanced
Platform: NinjaTrader, ThinkOrSwim
Trading: Futures, Options, Stocks
Posts: 19 since Jul 2020
Thanks Given: 4
Thanks Received: 2



sam028 View Post
Correct, it basically adds a new column in your dataframe.

Thx


Started this thread Reply With Quote




Last Updated on July 7, 2023


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts