andredumas / techan.js

A visual, technical analysis and charting (Candlestick, OHLC, indicators) library built on D3.
http://techanjs.org/
MIT License
2.39k stars 533 forks source link

a reusable framework that help user write his own indicator #37

Open GodRtio opened 9 years ago

GodRtio commented 9 years ago

Hi @andredumas,

I think it would be great if user can write his own indicator in javascript or coffee-script on the fly or save it to use later.

For example: A simple fractal indicator: if(data[i].high > data[i-1].high && data[i].high > data[i-2].high && data[i].high > data[i+1].high && data[i].high > data[i+2].high){ draw_symbol("fractal up" + i, i, fractalUpCode, color) } else if(data[i].low < data[i-1].low && data[i].low < data[i-2].low && data[i].low < data[i+1].low && data[i].low < data[i+2].low ){ draw_symbol("fractal down" + i, i, fractalDownCode, color) }

Basically, we need a framework to draw something, like: draw_line(id of line, position, type=trend|vertical|horizontal, style=solid|dash|dot, color) draw_circle(...) draw_rectangle(...) draw_symbol(...)

And a way to manipulate data that have basic function like access to any position of data to do calculation min, max function ....

I don't know if it easy to write, but if you need any help, i can work with you. Currently, i still read your code to understand the logic behind it.

Merry Christmas, @andredumas

GodRtio

andredumas commented 9 years ago

Hi @GodRtio

Initially this library started out to be like that, a higher financial abstraction layer, but it's morphed into something different. I'm noticing adding indicators could and probably should be easier.

Regardless of above, techanjs is designed to be non intrusive. Those functions you require (line, rectangle, symbol) are already already in core d3 and is what techanjs fundamentally uses to do it's job. See here or here. There is nothing stopping you from building a basic financial chart using techanjs, then using d3 directly for custom code, you could literally create a few d3 line objects to do what you require.

andre

andredumas commented 9 years ago

@GodRtio I will look into this, possibly a seed project for indicators or analysis functions with examples that allows access to techanjs internals.

GodRtio commented 9 years ago

Thank very much for your reply, andre

I have done a simple forex simulator let user practice trading when market is closed on weekend. http://i.imgur.com/jAgjFrq.png

I will learn D3 and read your code to see if i can add anything.