-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Candles stream v.1.0 | ||
class CandleStreams | ||
{ | ||
double OpenStream[]; | ||
double CloseStream[]; | ||
double HighStream[]; | ||
double LowStream[]; | ||
double ColorIndex[]; | ||
color colors[]; | ||
int streamIndex; | ||
public: | ||
CandleStreams(int streamIndex) | ||
{ | ||
this.streamIndex = streamIndex; | ||
} | ||
void Init() | ||
{ | ||
ArrayInitialize(OpenStream, EMPTY_VALUE); | ||
ArrayInitialize(CloseStream, EMPTY_VALUE); | ||
ArrayInitialize(HighStream, EMPTY_VALUE); | ||
ArrayInitialize(LowStream, EMPTY_VALUE); | ||
ArrayInitialize(ColorIndex, 0); | ||
} | ||
|
||
void Clear(const int index) | ||
{ | ||
OpenStream[index] = EMPTY_VALUE; | ||
CloseStream[index] = EMPTY_VALUE; | ||
HighStream[index] = EMPTY_VALUE; | ||
LowStream[index] = EMPTY_VALUE; | ||
ColorIndex[index] = 0; | ||
} | ||
|
||
void AddColor(color clr) | ||
{ | ||
int size = ArraySize(colors); | ||
ArrayResize(colors, size + 1); | ||
colors[size] = clr; | ||
} | ||
|
||
int RegisterStreams(const int id) | ||
{ | ||
SetIndexBuffer(id, OpenStream, INDICATOR_DATA); | ||
SetIndexBuffer(id + 1, HighStream, INDICATOR_DATA); | ||
SetIndexBuffer(id + 2, LowStream, INDICATOR_DATA); | ||
SetIndexBuffer(id + 3, CloseStream, INDICATOR_DATA); | ||
SetIndexBuffer(id + 4, ColorIndex, INDICATOR_COLOR_INDEX); | ||
int size = ArraySize(colors); | ||
PlotIndexSetInteger(streamIndex, PLOT_COLOR_INDEXES, size); | ||
for (int i = 0; i < size; ++i) | ||
{ | ||
PlotIndexSetInteger(streamIndex, PLOT_LINE_COLOR, i, colors[i]); | ||
} | ||
return id + 5; | ||
} | ||
|
||
void Set(const int index, const double open, const double high, const double low, const double close, color clr) | ||
{ | ||
if (clr == (color)EMPTY_VALUE) | ||
{ | ||
return; | ||
} | ||
OpenStream[index] = open; | ||
HighStream[index] = high; | ||
LowStream[index] = low; | ||
CloseStream[index] = close; | ||
ColorIndex[index] = FindColor(clr); | ||
} | ||
|
||
void SetOffset(int offset) | ||
{ | ||
} | ||
private: | ||
int FindColor(color clr) | ||
{ | ||
int size = ArraySize(colors); | ||
for (int i = 0; i < size; ++i) | ||
{ | ||
if (colors[i] == clr) | ||
{ | ||
return i; | ||
} | ||
} | ||
return 0; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters