last works ...
This commit is contained in:
@@ -37,15 +37,17 @@
|
||||
input group "Market";
|
||||
input int strLength = 14; // Length
|
||||
input double strMultiplier = 3; // Multiplier
|
||||
input ENUM_MA_METHOD strBoundaryMode = MODE_SMA; // Boundary Mode
|
||||
input ENUM_APPLIED_PRICE strAppliedTo = PRICE_MEDIAN; // Applied To
|
||||
|
||||
//
|
||||
input group "Presentation";
|
||||
|
||||
//
|
||||
input bool showStr = true; // Show Str
|
||||
input bool showStrUpper = true; // Show Str Upper
|
||||
input bool showStrLower = true; // Show Str Lower
|
||||
input bool showStr = true; // Show Str
|
||||
input bool showStrMid = true; // Show Str Mid
|
||||
input bool showStrUpper = true; // Show Str Upper
|
||||
input bool showStrLower = true; // Show Str Lower
|
||||
input bool showStrLowMa = true; // Show Low Smoothed Buffer
|
||||
input bool showStrHighMa = true; // Show High Smoothed Buffer
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
@@ -56,12 +58,15 @@ input bool showStrLower = true; // Show Str Lower
|
||||
#define bearishColorIDX 2
|
||||
#define neuturalColorIDX 3
|
||||
|
||||
//
|
||||
#define emptyValue 0.0
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 7
|
||||
#property indicator_plots 3
|
||||
#property indicator_buffers 11
|
||||
#property indicator_plots 6
|
||||
|
||||
//
|
||||
// STR ...
|
||||
@@ -88,7 +93,7 @@ double strUpBuffer[];
|
||||
#define strUpPlotBufferIndex 1
|
||||
#property indicator_label2 "X121 STR U"
|
||||
#property indicator_type2 DRAW_LINE
|
||||
#property indicator_color2 C'255,106,0'
|
||||
#property indicator_color2 clrBlueViolet
|
||||
#property indicator_style2 STYLE_SOLID
|
||||
#property indicator_width2 1
|
||||
|
||||
@@ -101,15 +106,57 @@ double strDownBuffer[];
|
||||
#define strDownPlotBufferIndex 2
|
||||
#property indicator_label3 "X121 STR D"
|
||||
#property indicator_type3 DRAW_LINE
|
||||
#property indicator_color3 C'255,106,0'
|
||||
#property indicator_color3 clrBlueViolet
|
||||
#property indicator_style3 STYLE_SOLID
|
||||
#property indicator_width3 1
|
||||
|
||||
//
|
||||
// High MA ...
|
||||
#define strHighMaBufferIndex 4
|
||||
double strHighMaBuffer[];
|
||||
|
||||
//
|
||||
#define strHighMaPlotBufferIndex 3
|
||||
#property indicator_label4 "X121 STR HSM"
|
||||
#property indicator_type4 DRAW_LINE
|
||||
#property indicator_color4 clrAqua
|
||||
#property indicator_style4 STYLE_SOLID
|
||||
#property indicator_width4 1
|
||||
|
||||
//
|
||||
// Low Ma ...
|
||||
#define strLowMaBufferIndex 5
|
||||
double strLowMaBuffer[];
|
||||
|
||||
//
|
||||
#define strLowMaPlotBufferIndex 4
|
||||
#property indicator_label5 "X121 STR LSM"
|
||||
#property indicator_type5 DRAW_LINE
|
||||
#property indicator_color5 clrMagenta
|
||||
#property indicator_style5 STYLE_SOLID
|
||||
#property indicator_width5 1
|
||||
|
||||
//
|
||||
// STR Mmid ...
|
||||
#define strMidBufferIndex 6
|
||||
double strMidBuffer[];
|
||||
|
||||
#define strMidColorBufferIndex 7
|
||||
double strMidColorBuffer[];
|
||||
|
||||
//
|
||||
#define strMidPlotBufferIndex 5
|
||||
#property indicator_label6 "X121 STR Mid"
|
||||
#property indicator_type6 DRAW_COLOR_LINE
|
||||
#property indicator_color6 CLR_NONE, clrLime, clrRed, clrGray
|
||||
#property indicator_style6 STYLE_SOLID
|
||||
#property indicator_width6 1
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
//
|
||||
int mLastBufferIndex = 3;
|
||||
int mLastBufferIndex = 7;
|
||||
|
||||
//
|
||||
// STR ...
|
||||
@@ -143,6 +190,11 @@ int maxLength;
|
||||
// ATR Handler ...
|
||||
int atrHandler = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
// MA Handler ...
|
||||
int lowMaHandler = INVALID_HANDLE;
|
||||
int highMaHandler = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
bool isStrTrendChanged;
|
||||
bool isStrStartBearishTrend;
|
||||
@@ -186,6 +238,38 @@ int OnInit()
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// Low Ma ...
|
||||
lowMaHandler = iMA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
strLength,
|
||||
0,
|
||||
strBoundaryMode,
|
||||
PRICE_LOW //
|
||||
);
|
||||
isInited = lowMaHandler != INVALID_HANDLE;
|
||||
if (!isInited)
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// High Ma ...
|
||||
highMaHandler = iMA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
strLength,
|
||||
0,
|
||||
strBoundaryMode,
|
||||
PRICE_HIGH //
|
||||
);
|
||||
isInited = highMaHandler != INVALID_HANDLE;
|
||||
if (!isInited)
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// because in some cases we may have more than one input for
|
||||
// calculation and we must prevent any calculation
|
||||
@@ -227,6 +311,8 @@ void OnDeinit(const int reason)
|
||||
|
||||
//
|
||||
IndicatorRelease(atrHandler);
|
||||
IndicatorRelease(lowMaHandler);
|
||||
IndicatorRelease(highMaHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,11 +354,25 @@ int OnCalculate(
|
||||
// ATR ...
|
||||
int atrCalculatedBars = BarsCalculated(atrHandler);
|
||||
|
||||
//
|
||||
// Low Ma ...
|
||||
int lowMaCalculatedBars = BarsCalculated(lowMaHandler);
|
||||
|
||||
//
|
||||
// High Ma ...
|
||||
int highMaCalculatedBars = BarsCalculated(highMaHandler);
|
||||
|
||||
//
|
||||
bool isPassedRequiredCalculatedBars =
|
||||
//
|
||||
// ATR ...
|
||||
atrCalculatedBars >= 0
|
||||
atrCalculatedBars >= 0 &&
|
||||
//
|
||||
// Low Ma ...
|
||||
lowMaCalculatedBars >= 0 &&
|
||||
//
|
||||
// High Ma ...
|
||||
highMaCalculatedBars >= 0
|
||||
//
|
||||
;
|
||||
if (!isPassedRequiredCalculatedBars)
|
||||
@@ -295,12 +395,26 @@ int OnCalculate(
|
||||
// ATR ...
|
||||
int copiedAtrs = CopyBuffer(atrHandler, 0, 0, rates_total, atrBuffer);
|
||||
|
||||
//
|
||||
// Low Ma ...
|
||||
int copiedLowMas = CopyBuffer(lowMaHandler, 0, 0, rates_total, strLowMaBuffer);
|
||||
|
||||
//
|
||||
// High Ma ...
|
||||
int copiedHighMas = CopyBuffer(highMaHandler, 0, 0, rates_total, strHighMaBuffer);
|
||||
|
||||
//
|
||||
// Validate Copied Items ...
|
||||
bool isPassedRequiredCopiedItems =
|
||||
//
|
||||
// ATR ...
|
||||
copiedAtrs >= 0
|
||||
copiedAtrs >= 0 &&
|
||||
//
|
||||
// Low Ma ...
|
||||
copiedLowMas >= 0 &&
|
||||
//
|
||||
// Hig Ma ...
|
||||
copiedHighMas >= 0
|
||||
//
|
||||
;
|
||||
if (!isPassedRequiredCopiedItems)
|
||||
@@ -383,22 +497,41 @@ void DefineBuffers()
|
||||
//
|
||||
ENUM_DRAW_TYPE strUpDrawType = showStrUpper ? DRAW_LINE : DRAW_NONE;
|
||||
SetIndexBuffer(strUpBufferIndex, strUpBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(strUpPlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetDouble(strUpPlotBufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(strUpPlotBufferIndex, PLOT_SHOW_DATA, showStrUpper);
|
||||
PlotIndexSetInteger(strUpPlotBufferIndex, PLOT_DRAW_TYPE, strUpDrawType);
|
||||
|
||||
//
|
||||
ENUM_DRAW_TYPE strDownDrawType = showStrLower ? DRAW_LINE : DRAW_NONE;
|
||||
SetIndexBuffer(strDownBufferIndex, strDownBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(strDownPlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetDouble(strDownPlotBufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(strDownPlotBufferIndex, PLOT_SHOW_DATA, showStrLower);
|
||||
PlotIndexSetInteger(strDownPlotBufferIndex, PLOT_DRAW_TYPE, strDownDrawType);
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
ENUM_DRAW_TYPE strLowMaDrawType = showStrLowMa ? DRAW_LINE : DRAW_NONE;
|
||||
SetIndexBuffer(strLowMaBufferIndex, strLowMaBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(strLowMaPlotBufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(strLowMaPlotBufferIndex, PLOT_SHOW_DATA, showStrLowMa);
|
||||
PlotIndexSetInteger(strLowMaPlotBufferIndex, PLOT_DRAW_TYPE, strLowMaDrawType);
|
||||
|
||||
//
|
||||
// STR ...
|
||||
ENUM_DRAW_TYPE strHighMaDrawType = showStrHighMa ? DRAW_LINE : DRAW_NONE;
|
||||
SetIndexBuffer(strHighMaBufferIndex, strHighMaBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetDouble(strHighMaPlotBufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(strHighMaPlotBufferIndex, PLOT_SHOW_DATA, showStrHighMa);
|
||||
PlotIndexSetInteger(strHighMaPlotBufferIndex, PLOT_DRAW_TYPE, strHighMaDrawType);
|
||||
|
||||
//
|
||||
ENUM_DRAW_TYPE strMidDrawType = showStrMid ? DRAW_COLOR_LINE : DRAW_NONE;
|
||||
SetIndexBuffer(strMidBufferIndex, strMidBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(strMidColorBufferIndex, strMidColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
PlotIndexSetDouble(strMidPlotBufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(strMidPlotBufferIndex, PLOT_SHOW_DATA, showStrMid);
|
||||
PlotIndexSetInteger(strMidPlotBufferIndex, PLOT_DRAW_TYPE, strMidDrawType);
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
//
|
||||
SetIndexBuffer(strPriceBufferIndex, strPriceBuffer, INDICATOR_CALCULATIONS);
|
||||
@@ -460,10 +593,16 @@ void FillBuffersZero(int barIndex)
|
||||
{
|
||||
//
|
||||
// STR ...
|
||||
strBuffer[barIndex] = 0;
|
||||
strUpBuffer[barIndex] = 0;
|
||||
strDownBuffer[barIndex] = 0;
|
||||
strPriceBuffer[barIndex] = 0;
|
||||
strBuffer[barIndex] = emptyValue;
|
||||
strUpBuffer[barIndex] = emptyValue;
|
||||
strMidBuffer[barIndex] = emptyValue;
|
||||
strMidBuffer[barIndex] = emptyValue;
|
||||
strDownBuffer[barIndex] = emptyValue;
|
||||
strPriceBuffer[barIndex] = emptyValue;
|
||||
strLowMaBuffer[barIndex] = emptyValue;
|
||||
strHighMaBuffer[barIndex] = emptyValue;
|
||||
|
||||
//
|
||||
strColorBuffer[barIndex] = hideColorIDX;
|
||||
strStateBuffer[barIndex] = hideColorIDX;
|
||||
}
|
||||
@@ -491,9 +630,9 @@ void CalculateStr(
|
||||
{
|
||||
//
|
||||
// Calculated Price ...
|
||||
ENUM_X_PRICE mPTYpe = ToXPrice(strAppliedTo);
|
||||
ENUM_X_PRICE mPType = ToXPrice(strAppliedTo);
|
||||
double price = GetAppliedPrice(
|
||||
mPTYpe,
|
||||
mPType,
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
@@ -632,6 +771,23 @@ void CalculateStr(
|
||||
{
|
||||
strColorBuffer[bar_index] = colorIDX;
|
||||
}
|
||||
|
||||
//
|
||||
// Str Mid ...
|
||||
|
||||
//
|
||||
double iStrMid = strDownBuffer[bar_index] + ((strUpBuffer[bar_index] - strDownBuffer[bar_index]) / 2);
|
||||
strMidBuffer[bar_index] = iStrMid;
|
||||
|
||||
//
|
||||
double iStrColor = close[bar_index] > strMidBuffer[bar_index]
|
||||
? bullishColorIDX
|
||||
: close[bar_index] < strMidBuffer[bar_index]
|
||||
? bearishColorIDX
|
||||
: neuturalColorIDX;
|
||||
strMidColorBuffer[bar_index] = iStrColor;
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user