NexusFi: Find Your Edge


Home Menu

 





pandas df.diff() func


Discussion in Platforms and Indicators

Updated
    1. trending_up 1,262 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?
Khamenei Vetoes Uranium Transfer as Peace Odds Surge to …
Prediction Markets & Event Contracts
White House Drops First Alien Files Today -- Market Says …
Prediction Markets & Event Contracts
April Jobs Beat Flips Fed Hike Odds Past 52% for First T …
Traders Hideout
Iran Deal "In Review" at 87% on Deadline Day - …
Prediction Markets & Event Contracts
Ninjatrader users - good CONNECTIONs post and article fr …
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
6 thanks
Darmok and Jalad at Tanagra
1 thanks
  #2 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,758 since Jun 2009
Thanks Given: 3,828
Thanks Received: 4,643


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