last ...
This commit is contained in:
@@ -2930,6 +2930,247 @@ struct XMarketCycle
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Styling Buffers ...
|
||||
|
||||
//
|
||||
struct XBufferPlotStyle
|
||||
{
|
||||
//
|
||||
int width; // Width
|
||||
color clr; // Color
|
||||
uchar arrow; // Arrow Code
|
||||
ENUM_DRAW_TYPE type; // Type
|
||||
ENUM_LINE_STYLE style; // Style
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XBufferPlotStyle()
|
||||
{
|
||||
Default();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
width = 1;
|
||||
arrow = 0;
|
||||
clr = CLR_NONE;
|
||||
type = DRAW_NONE;
|
||||
style = STYLE_SOLID;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Register a Buffer as Indexed Buffer ...
|
||||
void SetIndexBuffer(
|
||||
int &index, // the Index refrence for Buffer
|
||||
double &buffer[], // Buffer to Set
|
||||
XBufferPlotStyle &style, // Style to Apply to Buffer
|
||||
double &colorBuffer[], // Color Buffer
|
||||
string label = NULL, // Buffer Label
|
||||
bool showData = true, // Show Data on Data Window
|
||||
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
|
||||
int drawBegin = -1 // if Set More Than -1 applied
|
||||
)
|
||||
{
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, buffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
// Show Date ...
|
||||
PlotIndexSetInteger(index, PLOT_SHOW_DATA, showData);
|
||||
|
||||
//
|
||||
// Set Buffer Label ...
|
||||
if (IsValid(label))
|
||||
{
|
||||
PlotIndexSetString(index, PLOT_LABEL, label);
|
||||
}
|
||||
|
||||
//
|
||||
if (empty == 0 || empty == EMPTY_VALUE)
|
||||
{
|
||||
PlotIndexSetDouble(index, PLOT_EMPTY_VALUE, empty);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawBegin > -1)
|
||||
{
|
||||
PlotIndexSetInteger(index, PLOT_DRAW_BEGIN, drawBegin);
|
||||
}
|
||||
|
||||
//
|
||||
if (style.type == DRAW_ARROW)
|
||||
{
|
||||
PlotIndexSetInteger(index, PLOT_ARROW, style.arrow);
|
||||
}
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(index, PLOT_LINE_STYLE, style.style);
|
||||
PlotIndexSetInteger(index, PLOT_LINE_WIDTH, style.width);
|
||||
|
||||
//
|
||||
string drawTypeStr = EnumToString(style.type);
|
||||
bool hasColorBuffer = Contains("COLOR", drawTypeStr);
|
||||
|
||||
//
|
||||
if (!hasColorBuffer)
|
||||
{
|
||||
PlotIndexSetInteger(index, PLOT_LINE_COLOR, style.clr);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Since Color Buffers must add as next Index of it's own Buffer
|
||||
// here before applied Color Buffer increase index ...
|
||||
index++;
|
||||
|
||||
//
|
||||
SetIndexBuffer(index, colorBuffer, INDICATOR_COLOR_INDEX);
|
||||
}
|
||||
|
||||
//
|
||||
// Increase Index for Next Buffer ...
|
||||
index++;
|
||||
}
|
||||
|
||||
//
|
||||
void SetIndexCandleBuffers(
|
||||
int &index, // the Index refrence for Buffer
|
||||
string openLabel, // Open Label
|
||||
double &open[], // Open Buffer
|
||||
string highLabel, // High Label
|
||||
double &high[], // High Buffer
|
||||
string lowLabel, // Low Label
|
||||
double &low[], // Low Buffer
|
||||
string closeLabel, // Close Label
|
||||
double &close[], // Close Buffer
|
||||
bool showData = true, // Show Data on Data Window
|
||||
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
|
||||
int drawBegin = -1 // if Set More Than -1 applied
|
||||
)
|
||||
{
|
||||
//
|
||||
bool hasLabel =
|
||||
//
|
||||
IsValid(openLabel) &&
|
||||
IsValid(highLabel) &&
|
||||
IsValid(lowLabel) &&
|
||||
IsValid(closeLabel)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
string label =
|
||||
!hasLabel
|
||||
? NULL
|
||||
: openLabel + ";" + highLabel + ";" + lowLabel + ";" + closeLabel;
|
||||
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, open, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
// Set Draw Candles Type ...
|
||||
PlotIndexSetInteger(index, PLOT_LINE_STYLE, DRAW_CANDLES);
|
||||
|
||||
//
|
||||
// Show Date ...
|
||||
PlotIndexSetInteger(index, PLOT_SHOW_DATA, showData);
|
||||
|
||||
//
|
||||
// Set Buffer Label ...
|
||||
if (IsValid(label))
|
||||
{
|
||||
PlotIndexSetString(index, PLOT_LABEL, label);
|
||||
}
|
||||
|
||||
//
|
||||
if (empty == 0 || empty == EMPTY_VALUE)
|
||||
{
|
||||
PlotIndexSetDouble(index, PLOT_EMPTY_VALUE, empty);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawBegin > -1)
|
||||
{
|
||||
PlotIndexSetInteger(index, PLOT_DRAW_BEGIN, drawBegin);
|
||||
}
|
||||
|
||||
//
|
||||
index++;
|
||||
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, high, INDICATOR_DATA);
|
||||
index++;
|
||||
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, low, INDICATOR_DATA);
|
||||
index++;
|
||||
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, close, INDICATOR_DATA);
|
||||
index++;
|
||||
}
|
||||
|
||||
//
|
||||
void SetIndexCandleBuffers(
|
||||
int &index, // the Index refrence for Buffer
|
||||
string openLabel, // Open Label
|
||||
double &open[], // Open Buffer
|
||||
string highLabel, // High Label
|
||||
double &high[], // High Buffer
|
||||
string lowLabel, // Low Label
|
||||
double &low[], // Low Buffer
|
||||
string closeLabel, // Close Label
|
||||
double &close[], // Close Buffer
|
||||
double &colorBuffer[], // Candle Color Buffer
|
||||
bool showData = true, // Show Data on Data Window
|
||||
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
|
||||
int drawBegin = -1 // if Set More Than -1 applied
|
||||
)
|
||||
{
|
||||
//
|
||||
SetIndexCandleBuffers(
|
||||
index,
|
||||
openLabel,
|
||||
open,
|
||||
highLabel,
|
||||
high,
|
||||
lowLabel,
|
||||
low,
|
||||
closeLabel,
|
||||
close,
|
||||
showData,
|
||||
empty,
|
||||
drawBegin //
|
||||
);
|
||||
|
||||
//
|
||||
int mFirstIndex = index - 4;
|
||||
|
||||
//
|
||||
// Set Draw Candles Type ...
|
||||
PlotIndexSetInteger(mFirstIndex, PLOT_LINE_STYLE, DRAW_COLOR_CANDLES);
|
||||
|
||||
//
|
||||
// Set Color Buffer ...
|
||||
SetIndexBuffer(index, colorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
index++;
|
||||
}
|
||||
|
||||
//
|
||||
// Functions ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user