Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TDA TimeSegmentedValue, TimeSegmentedValueRatio Indicators #431

Closed
hhashim1 opened this issue Nov 16, 2021 · 9 comments
Closed

TDA TimeSegmentedValue, TimeSegmentedValueRatio Indicators #431

hhashim1 opened this issue Nov 16, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@hhashim1
Copy link

hhashim1 commented Nov 16, 2021

Which version are you running? The lastest version is on Github. Pip is for major releases.

import pandas_ta as ta
print(ta.version)
0.3.14b0

Hi Kevin,

Do you think it is possible to create a couple of new indicators for me that I am currently using on TOS? Here is the thinkscript code for them. Thank you so much for your help.

### RelativeVolumeStDev:
Also known as: Absolute Zscore of Volume. Does not need to be implemented, see example in comments below. - KJ

#
# TD Ameritrade IP Company, Inc. (c) 2014-2021
#

declare lower;
declare zerobase;

input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
plot StDevLevel = numDev;

RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("Above", GetColor(0));
RelVol.DefineColor("Below", GetColor(2));
RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below"));
StDevLevel.SetDefaultColor(GetColor(7));
StDevLevel.SetStyle(Curve.SHORT_DASH);

### Time Segmented Value


input length = 18;
input avgLength = 10;


#TSV=(Sum( IIf( C > Ref(C,-1), V * ( C-Ref(C,-1) ),
# IIf( C < Ref(C,-1),-V * ( C-Ref(C,-1) ), 0 ) ) ,18));

def TSV = sum( if close > close[1] then volume * (close - close[1]) else if close < close[1] then -1* volume *(close - close[1]) else 0, length);

#Plot TSVAvg = Average( TSV,2);
##TSVAvg.SetDefaultColor(Color.GREEN);
#TSVAvg.SetLineWeight(3);
#TSVAvg.AssignValueColor(color.blue);
#TSVAvg.SetStyle(Curve.MEDIUM_DASH);
##TSVAvg.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

Plot TSVAvg2 = Average(TSV, avglength);
TSVAvg2.SetLineWeight(3);
TSVAvg2.AssignValueColor(color.yellow);
TSVAvg2.SetStyle(Curve.FIRM);
#TSVAvg2.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);


plot ZeroLine = 0;
ZeroLine.SetLineWeight(2);
ZeroLine.SetDefaultColor(Color.RED);
ZeroLine.SetStyle(Curve.SHORT_DASH);

plot TSV2 = TSV;

#TSV.SetDefaultColor(GetColor(1));
TSV2.SetLineWeight(1);
TSV2.AssignValueColor(if close > close[1] then color.green else color.red);
TSV2.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);



def tt = TSV / TSVAvg2;
#tt.SetLineWeight(3);
#tt.AssignValueColor(color.yellow);
#tt.SetStyle(Curve.SHORT_DASH);


AddLabel(yes, Round(tt, 2), if TSV > TSVAvg2 then if close > open then color.dark_green else color.yellow else color.white);

### Time Segmented Value Ratio:


input length = 18;
input avgLength = 10;


#TSV=(Sum( IIf( C > Ref(C,-1), V * ( C-Ref(C,-1) ),
# IIf( C < Ref(C,-1),-V * ( C-Ref(C,-1) ), 0 ) ) ,18));

def TSV = sum( if close > close[1] then volume * (close - close[1]) else if close < close[1] then -1* volume *(close - close[1]) else 0, length);

#Plot TSVAvg = Average( TSV,2);
##TSVAvg.SetDefaultColor(Color.GREEN);
#TSVAvg.SetLineWeight(3);
#TSVAvg.AssignValueColor(color.blue);
#TSVAvg.SetStyle(Curve.MEDIUM_DASH);
##TSVAvg.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

def TSVAvg2 = Average(TSV, avglength);

plot ZeroLine = 0;
ZeroLine.SetLineWeight(2);
ZeroLine.SetDefaultColor(Color.RED);
ZeroLine.SetStyle(Curve.MEDIUM_DASH);

#def TSV2 = TSV;



plot tt = TSV / TSVAvg2;
tt.SetLineWeight(3);
tt.AssignValueColor(color.yellow);
tt.SetStyle(Curve.SHORT_DASH);```
@hhashim1 hhashim1 added the enhancement New feature or request label Nov 16, 2021
@twopirllc twopirllc removed their assignment Nov 16, 2021
@twopirllc twopirllc added the help wanted Extra attention is needed label Nov 16, 2021
@twopirllc
Copy link
Owner

Hello @hhashim1,

They will be added to the list of indicators to be included. However, I can not guarantee they will be implemented any time soon unfortunately unless you or someone else is willing to do it. I am knee deep in unresolved Issues and prior indicator requests with little to no support from other users or developers. 😞 To that end, it has been labeled as another Help Wanted case.

Kind Regards,
KJ

@twopirllc twopirllc changed the title New Indicator Request ToS RelativeVolumeStd, TimeSegmentedValue, TimeSegmentedValueRatio Indicators Nov 16, 2021
@twopirllc
Copy link
Owner

@hhashim1,

Upon review of RelativeVolumeStDev source, it is essentially the zscore of volume input and therefore is no need to implement a separate indicator for this.

df = # ohlcv
df["relvolstd"] = ta.zscore(df["volume"], length=60) # with negative values
# OR
df["relvolstd"] = ta.zscore(df["volume"], length=60).abs() # with positive values
print(df)

Kind Regards,
KJ

@twopirllc twopirllc changed the title ToS RelativeVolumeStd, TimeSegmentedValue, TimeSegmentedValueRatio Indicators ToS TimeSegmentedValue, TimeSegmentedValueRatio Indicators Nov 16, 2021
@hhashim1
Copy link
Author

hhashim1 commented Nov 16, 2021 via email

@hhashim1
Copy link
Author

@twopirllc let me know if you need additional help with new development. I have some friends who have some bandwidth and are good at this kind of stuff. I can definitely ask them if they are willing to help out and take your lib to the next step.

@twopirllc
Copy link
Owner

@hhashim1,

Thanks for getting back to me.
👍🏼

I can definitely help with creating
indicators (at least the ones I have asked for). If you could give me a
quick 5 mins crash course on do's and dont's of your library, I can
definitely help out with that

Great! 😎 To that end...

  • Have your friends read this comment to see if they are interested in contributing. 😎
  • Install Python packages of TA Lib (if possible), yfinance, stochastic, and other suggested packages.
  • Install the development branch of Pandas TA.
    $ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development
  • Get familiar with the organization of the code base.
  • Be able to run all the example Jupyter Notebooks.
  • Here is a Roadmap for features, indicators Roadmap for features, indicators #299. Look it over. It needs some editing, but those are some things that I would like to achieve.
    • I recommend reading Creating a Custom Indicator: The Big 4 #355 and trying to implement Time Segmented Value described above. The hardest part will be the core logic of the desired indicator and not necessarily integrating the indicator into the library (easy part). Please let me know if the guide is not clear enough.
    • After adding an indicator to the library, consider working on Type stubs #404. It is a simple way to improve the library without worrying about breaking indicator calculations.
    • Go through the outstanding Issues that have labels such as Good First Issue, Help Wanted and Bug and try to resolve the Issues with separate Pull Requests.
  • Do not feel overwhelmed!

Cheers!
KJ

@hhashim1
Copy link
Author

hhashim1 commented Nov 17, 2021 via email

@twopirllc
Copy link
Owner

@hhashim1,

Great!

I am trying to get some of this done in the free time, so please be patient.

By the way, I have already updated the code to use Polygon as a data source
on top of AlphaAdvantage and Yahoo. My friend wrote a library for Polygon
and I have used his as he makes it super easy. He is working on making his
library the official Polygon library :-)

Great! Looking forward to it. A Polygon wrapper would be a nice additional resource. 😎

By the way, is it possible to have a Discord server for discussion and
support? I think its much faster and you won't be the one to be knee-deep
in answering questions. You will have other members who can always chime
in. You also have your collabs who can help.

Think about it. I am a member of a couple of other discord servers that are
support systems for other libraries and it makes it much easier on the
owner.

Sure. I can set up a Discord server, but only for serious collaborators. Once Pandas TA
reaches a level of maturity and hopefully low maintenance, I may consider opening it up
to users. 🤷🏼‍♂️ Time will tell.

Let's talk! Oh, you can email me directly. I emailed you last night so you
can respond to my personal email.

We will. 😎

KJ

@pssolanki111
Copy link

pssolanki111 commented Nov 17, 2021

hey @twopirllc

A Polygon wrapper would be a nice additional resource

As Hashim mentioned a friend of his wrote a wrapper for polygon.io as s data source, I am that friend :D
The lib is public alpha (v0.9.6) and I'm holding off production release v1.0.0 until the polygon lib team reaches out (I'm in conversations with Quinton, their CEO on slack and they have some internal things to do before the integration.

hashim and I (well more like Hashim alone :D ) is working towards adding that lib as a data source since polygon is a very fine data provider.

Sure. I can set up a Discord server, but only for serious collaborators.

If you wish, feel free to use the server I have setup for polygon lib support. I would create a private collab channel where only we three can see/send msgs (hashim is already a part of it). Once you feel the lib is mature enough to have its own server, feel free to create one or just open up that channel for public, however you wish. I don't have many members since I only published it a few days back.

Hashim mentioned to me yday about his convo with you in #431 . and we decided to help however we can :)

@twopirllc
Copy link
Owner

Hi @twopirllc,

As Hashim mentioned a friend of his wrote a wrapper for polygon.io as s data source, I am that friend :D
The lib is public alpha (v0.9.6) and I'm holding off production release v1.0.0 until the polygon lib team reaches out (I'm in conversations with Quinton, their CEO on slack and they have some internal things to do before the integration.

Nice to meet you! 😎 I connected the dots. 😁

Awesome! Congrats on getting included with Polygon integration with your library. 🥂

hashim and I (well more like Hashim alone :D ) is working towards adding that lib as a data source since polygon is a very fine data provider.

True. Long ago for my first Open Source Python package, I wrote an AlphaVantage API wrapper. Sadly I still haven't integrated it yet with Pandas TA. In due time.

If you wish, feel free to use the server I have setup for polygon lib support. I would create a private collab channel where only we three can see/send msgs (hashim is already a part of it). Once you feel the lib is mature enough to have its own server, feel free to create one or just open up that channel for public, however you wish. I don't have many members since I only published it a few days back.

Cool! I will join up soon!

Hashim mentioned to me yday about his convo with you in #431 . and we decided to help however we can :)

Cool! 😎 Thanks!

KJ

@twopirllc twopirllc changed the title ToS TimeSegmentedValue, TimeSegmentedValueRatio Indicators TDA TimeSegmentedValue, TimeSegmentedValueRatio Indicators Nov 19, 2021
@twopirllc twopirllc removed the help wanted Extra attention is needed label Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants