NexusFi: Find Your Edge


Home Menu

 





pandas df.diff() func


Discussion in Platforms and Indicators

Updated
    1. trending_up 1,164 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?
February NFP Preview -- Why This Mornings Jobs Number Co …
Traders Hideout
Post-Summit Market Verdict: ES -1%, NQ -1.5%, 10-Year Yi …
Traders Hideout
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #2 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,756 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,632


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)
Follow me on X 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