NexusFi: Find Your Edge


Home Menu

 





pandas df.diff() func


Discussion in Platforms and Indicators

Updated
    1. trending_up 1,351 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?
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Datafeed for Atas
Platforms and Indicators
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
Ninjatrader users - good CONNECTIONs post and article fr …
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 thanks
BERN ALGOS algo trading journal
1 thanks
  #2 (permalink)
 
sam028's Avatar
 sam028 
Site Administrator
 
Posts: 3,766 since Jun 2009
Thanks Given: 3,836
Thanks Received: 4,690


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