النتائج 1 إلى 6 من 6
- 09-07-2018, 12:41 PM #1
اعدادات ومكونات المؤشر موجوده ولكن من يستطيع تحولها الى مؤشر
المؤشر الاول :
//
// "00-STC_v103.mq4" -- Schaff Trend Cycle
// refer to http://www.fxstreet.com/education/tr...f-trend-cycle/
//
// Ver. 0.01 2008/10/27(Mon) initial version
// Ver. 1.00 2008/11/16(Sun) release version
// Ver. 1.01 2008/12/23(Tue) added bAlert
// Ver. 1.02 2008/12/23(Tue) added appliedPrice
// Ver. 1.03 2008/12/23(Tue) bugfixed: don't work in MTF mode
//
//
#property copyright "00 - [email protected]"
#property link "http://www.mql4.com/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 5 // 5:6184KB 4:5720KB 3:5244KB 2:4776KB 1:4304
#property indicator_color1 Yellow // 0: STC
#property indicator_color2 DodgerBlue // 1: Long trigger
#property indicator_color3 Crimson // 2: Short trigger
#property indicator_color4 0x80481e // 3: Long turn
#property indicator_color5 0x1e0a6e // 4: Short turn
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_width5 1
#property indicator_style1 STYLE_SOLID
#property indicator_minimum -20
#property indicator_maximum 120
//---- defines
#define LONG_MARK_POS -5
#define SHORT_MARK_POS 105
//---- indicator parameters
extern int timeFrame = 0; // time frame
extern int nFast = 23; // EMA fast
extern int nSlow = 50; // EMA slow
extern int nStochas = 10; // Stochas period
extern bool bDoubleStochas = true; // apply stochas twice
extern int appliedPrice = PRICE_TYPICAL; // 0:CLOSE 1:OPEN 2:HIGH 3:LOW 4:MEDIAN 5:TYPICAL 6:WEIGHTED
extern double levelLo = 5; // lower level for long signal
extern double levelHi = 95; // upper level for short signal
extern double clearLo = 25; // lower level to clear long turn
extern double clearHi = 75; // upper level to clear short turn
extern bool bAlert = false; // PlaySound() on signal
extern int nMaxBars = 2000; // maximum number of bars to calculate, 0: no limit
//---- indicator buffers
double BufferSTC[]; // 0: STC
double BufferLongTrigger[]; // 1: Long trigger
double BufferShortTrigger[]; // 2: Short trigger
double BufferLongTurn[]; // 3: Long turn
double BufferShortTurn[]; // 4: Short turn
//---- vars
string sIndicatorName;
string sIndSelf = "00-STC_v103";
int markLongTrigger = 233;
int markLongTurn = 167;
int markShortTrigger = 234;
int markShortTurn = 167;
int lastBars;
double bufMacd[];
double bufStoK1[];
double bufStoD1[];
double bufStoK2[];
datetime tAlertLast;
//----------------------------------------------------------------------
string TimeFrameToStr(int timeFrame)
{
switch (timeFrame) {
case 1: return("M1");
case 5: return("M5");
case 15: return("M15");
case 30: return("M30");
case 60: return("H1");
case 240: return("H4");
case 1440: return("D1");
case 10080: return("W1");
case 43200: return("MN");
}
return("??");
}
//----------------------------------------------------------------------
void init()
{
if (timeFrame == 0) {
timeFrame = Period();
}
string tf = TimeFrameToStr(timeFrame);
sIndicatorName = sIndSelf + "(" + tf + "," + nStochas + "," + nFast + "," + nSlow + ")";
IndicatorShortName(sIndicatorName);
SetIndexBuffer(0, BufferSTC);
SetIndexBuffer(1, BufferLongTrigger);
SetIndexBuffer(2, BufferShortTrigger);
SetIndexBuffer(3, BufferLongTurn);
SetIndexBuffer(4, BufferShortTurn);
SetIndexLabel(0, "STC");
SetIndexLabel(1, "Long trigger");
SetIndexLabel(2, "Short trigger");
SetIndexLabel(3, "Long turn");
SetIndexLabel(4, "Short turn");
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_ARROW);
SetIndexStyle(2, DRAW_ARROW);
SetIndexStyle(3, DRAW_ARROW);
SetIndexStyle(4, DRAW_ARROW);
SetIndexArrow(1, markLongTrigger);
SetIndexArrow(2, markShortTrigger);
SetIndexArrow(3, markLongTurn);
SetIndexArrow(4, markShortTurn);
int n = MathMax(nFast, nSlow) + nStochas;
if (nMaxBars > 0) {
n += Bars - MathMin(Bars, nMaxBars);
}
SetIndexDrawBegin(0, n);
SetIndexDrawBegin(1, n);
SetIndexDrawBegin(2, n);
SetIndexDrawBegin(3, n);
SetIndexDrawBegin(4, n);
SetLevelValue(0, levelLo);
SetLevelValue(1, levelHi);
}
//----------------------------------------------------------------------
void arrayMove(double array[], int to, int from)
{
static double tmp[];
int n = ArraySize(tmp);
if (n < ArraySize(array)) {
ArrayResize(tmp, ArraySize(array));
n = ArraySize(tmp);
}
int d = to - from;
ArrayCopy(tmp, array, 0, 0, n - d);
ArrayCopy(array, tmp, to, from, n - d);
}
//----------------------------------------------------------------------
void start()
{
int limit;
int counted_bars = IndicatorCounted();
if (counted_bars > 0) {
counted_bars--;
}
limit = Bars - counted_bars;
int limit0 = limit;
if (nMaxBars > 0) {
limit = MathMin(limit, nMaxBars);
}
// setup work buffers
if (lastBars != Bars) {
int n = Bars;
if (nMaxBars > 0) {
n = nMaxBars;
}
if (ArraySize(bufMacd) != n) {
ArrayResize(bufMacd, n);
ArrayResize(bufStoK1, n);
ArrayResize(bufStoD1, n);
ArrayResize(bufStoK2, n);
}
n = Bars - lastBars;
arrayMove(bufMacd, n, 0);
arrayMove(bufStoK1, n, 0);
arrayMove(bufStoD1, n, 0);
arrayMove(bufStoK2, n, 0);
lastBars = Bars;
}
// clear beyond limits
for (int i = limit0 - 1; i >= limit; i--) {
BufferSTC[i] = 0;
BufferLongTrigger[i] = EMPTY_VALUE;
BufferShortTrigger[i] = EMPTY_VALUE;
BufferLongTurn[i] = EMPTY_VALUE;
BufferShortTurn[i] = EMPTY_VALUE;
}
if (timeFrame != Period()) {
// MTF
limit = MathMax(limit, timeFrame / Period());
for (i = limit - 1; i >= 0; i--) {
int shift = iBarShift(NULL, timeFrame, Time[i]);
BufferSTC[i] = iCustom(NULL, timeFrame, sIndSelf, 0, nFast, nSlow, nStochas, bDoubleStochas,
appliedPrice, levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 0, shift);
BufferLongTrigger[i] = iCustom(NULL, timeFrame, sIndSelf, 0, nFast, nSlow, nStochas, bDoubleStochas,
appliedPrice, levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 1, shift);
BufferShortTrigger[i] = iCustom(NULL, timeFrame, sIndSelf, 0, nFast, nSlow, nStochas, bDoubleStochas,
appliedPrice, levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 2, shift);
BufferLongTurn[i] = iCustom(NULL, timeFrame, sIndSelf, 0, nFast, nSlow, nStochas, bDoubleStochas,
appliedPrice, levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 3, shift);
BufferShortTurn[i] = iCustom(NULL, timeFrame, sIndSelf, 0, nFast, nSlow, nStochas, bDoubleStochas,
appliedPrice, levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 4, shift);
if (bAlert && i == 0) {
bool bFire = (BufferLongTrigger[0] != EMPTY_VALUE || BufferShortTrigger[0] != EMPTY_VALUE);
if (bFire && tAlertLast != Time[0]) {
PlaySound("alert.wav");
tAlertLast = Time[0];
}
}
}
return;
}
// timeFrame == Period()
for (i = limit - 1; i >= 0; i--) {
BufferLongTrigger[i] = EMPTY_VALUE;
BufferShortTrigger[i] = EMPTY_VALUE;
BufferLongTurn[i] = EMPTY_VALUE;
BufferShortTurn[i] = EMPTY_VALUE;
// stochas on MACD
bufMacd[i] = iMACD(NULL, 0, nFast, nSlow, 1, appliedPrice, MODE_MAIN, i);
double min = bufMacd[ArrayMinimum(bufMacd, nStochas, i)];
double range = bufMacd[ArrayMaximum(bufMacd, nStochas, i)] - min;
if (range > 0) {
bufStoK1[i] = ((bufMacd[i] - min) / range) * 100.0;
} else {
bufStoK1[i] = bufStoK1[i + 1];
}
if (!bDoubleStochas) {
// single stochas
// STC value
BufferSTC[i] = BufferSTC[i + 1] + 0.5 * (bufStoK1[i] - BufferSTC[i + 1]);
} else {
// double stochas, stochas on stochas
bufStoD1[i] = bufStoD1[i + 1] + 0.5 * (bufStoK1[i] - bufStoD1[i + 1]);
min = bufStoD1[ArrayMinimum(bufStoD1, nStochas, i)];
range = bufStoD1[ArrayMaximum(bufStoD1, nStochas, i)] - min;
if (range > 0) {
bufStoK2[i] = ((bufStoD1[i] - min) / range) * 100.0;
} else {
bufStoK2[i] = bufStoK2[i + 1];
}
// STC value
BufferSTC[i] = BufferSTC[i + 1] + 0.5 * (bufStoK2[i] - BufferSTC[i + 1]);
}
// check signal
bFire = false;
double stc2 = BufferSTC[i + 2];
double stc1 = BufferSTC[i + 1];
if (stc2 <= levelLo && stc1 > levelLo) {
// long signal
bFire = true;
BufferLongTrigger[i] = LONG_MARK_POS;
BufferLongTurn[i] = LONG_MARK_POS;
BufferShortTurn[i + 1] = EMPTY_VALUE;
} else if (stc2 >= levelHi && stc1 < levelHi) {
// short signal
bFire = true;
BufferShortTrigger[i] = SHORT_MARK_POS;
BufferShortTurn[i] = SHORT_MARK_POS;
BufferLongTurn[i + 1] = EMPTY_VALUE;
}
if (BufferLongTrigger[i + 1] != EMPTY_VALUE || BufferLongTurn[i + 1] != EMPTY_VALUE) {
BufferLongTurn[i] = LONG_MARK_POS;
}
if (BufferShortTrigger[i + 1] != EMPTY_VALUE || BufferShortTurn[i + 1] != EMPTY_VALUE) {
BufferShortTurn[i] = SHORT_MARK_POS;
}
if (stc1 < stc2 && stc1 < clearLo) {
BufferLongTurn[i] = EMPTY_VALUE;
}
if (stc1 > stc2 && stc1 > clearHi) {
BufferShortTurn[i] = EMPTY_VALUE;
}
if (bAlert) {
if (i == 0 && bFire && tAlertLast != Time[0]) {
PlaySound("alert.wav");
tAlertLast = Time[0];
}
}
}
}
- 09-07-2018, 12:42 PM #2
المؤشر الثانى :
//
// "00-MultiSTC_v103.mq4" -- multiple time frame Schaff Trend Cycle
//
// Ver. 0.01 2008/10/30(Thu) initial version
// Ver. 1.00 2008/11/16(Sun) release version
// Ver. 1.03 2008/12/23(Tue) version sync
//
//
#property copyright "00 - [email protected]"
#property link "http://www.mql4.com/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 DodgerBlue // 0: Long signal
#property indicator_color2 Crimson // 1: Short signal
#property indicator_color3 0x80481e // 2: Long turn
#property indicator_color4 0x1e0a6e // 3: Short turn
#property indicator_color5 Yellow // 4: STC, timeFrame0
#property indicator_color6 Gold // 5: STC, timeFrame1
#property indicator_color7 Orange // 6: STC, timeFrame2
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
#property indicator_style3 STYLE_SOLID
#property indicator_style4 STYLE_SOLID
#property indicator_style5 STYLE_SOLID
#property indicator_style6 STYLE_SOLID
#property indicator_style7 STYLE_DOT
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_width5 3
#property indicator_width6 1
#property indicator_width7 1
#property indicator_minimum -20
#property indicator_maximum 120
//---- defines
#define LONG_MARK_POS -5
#define SHORT_MARK_POS 105
//---- indicator parameters
extern int timeFrame0 = 0; // time frame 0
extern int timeFrame1 = 0; // time frame 1
extern int timeFrame2 = 0; // time frame 2
extern bool bAlert = false; // PlaySound() on signal
//
/*extern*/ string sHelp0 = "--- params for "00-STC"";
/*extern*/ string sIndSTC = "00-STC_v103"; // indicator name
extern int nFast = 23; // EMA fast
extern int nSlow = 50; // EMA slow
extern int nStochas = 10; // Stochas period
extern bool bDoubleStochas = true; // apply stochas twice
extern int appliedPrice = PRICE_TYPICAL; // 0:CLOSE 1:OPEN 2:HIGH 3:LOW 4:MEDIAN 5:TYPICAL 6:WEIGHTED
extern double levelLo = 5; // lower threshold for long signal
extern double levelHi = 95; // upper threshold for short signal
extern double clearLo = 25; // lower level to clear long turn
extern double clearHi = 75; // upper level to clear short turn
extern int nMaxBars = 2000; // maximum number of bars to calculate, 0: no limit
/*extern*/ string sHelp1 = "--- end of params for "00-STC"";
//---- indicator buffers
double BufferLongTrigger[]; // 0: Long trigger
double BufferShortTrigger[]; // 1: Short trigger
double BufferLongTurn[]; // 2: Long turn
double BufferShortTurn[]; // 3: Short turn
double BufferSTC0[]; // 4: STC, timeFrame0
double BufferSTC1[]; // 5: STC, timeFrame1
double BufferSTC2[]; // 6: STC, timeFrame2
//---- vars
string sIndicatorName = "00-MultiSTC_v103";
int markLongTrigger = 233;
int markLongTurn = 167;
int markShortTrigger = 234;
int markShortTurn = 167;
datetime tAlertLast;
//----------------------------------------------------------------------
string TimeFrameToStr(int timeFrame)
{
switch (timeFrame) {
case 1: return("M1");
case 5: return("M5");
case 15: return("M15");
case 30: return("M30");
case 60: return("H1");
case 240: return("H4");
case 1440: return("D1");
case 10080: return("W1");
case 43200: return("MN");
}
return("??");
}
//----------------------------------------------------------------------
int NextPeriod(int timeFrame)
{
switch (timeFrame) {
case 1: return(5);
case 5: return(15);
case 15: return(30);
case 30: return(60);
case 60: return(240);
case 240: return(1440);
case 1440: return(10080);
case 10080: return(43200);
}
return(0);
}
//----------------------------------------------------------------------
void init()
{
if (timeFrame0 == 0 && timeFrame1 == 0 && timeFrame2 == 0) {
timeFrame0 = Period();
timeFrame1 = NextPeriod(timeFrame0);
timeFrame2 = NextPeriod(timeFrame1);
}
if (timeFrame0 == 0) {
timeFrame0 = Period();
}
if (timeFrame1 == 0) {
timeFrame1 = Period();
}
if (timeFrame2 == 0) {
timeFrame2 = Period();
}
sIndicatorName = (sIndicatorName + "(" +
TimeFrameToStr(timeFrame0) + "," +
TimeFrameToStr(timeFrame1) + "," +
TimeFrameToStr(timeFrame2) + ")");
IndicatorShortName(sIndicatorName);
SetIndexBuffer(0, BufferLongTrigger);
SetIndexBuffer(1, BufferShortTrigger);
SetIndexBuffer(2, BufferLongTurn);
SetIndexBuffer(3, BufferShortTurn);
SetIndexBuffer(4, BufferSTC0);
SetIndexBuffer(5, BufferSTC1);
SetIndexBuffer(6, BufferSTC2);
SetIndexLabel(0, "Long trigger");
SetIndexLabel(1, "Short trigger");
SetIndexLabel(2, "Long turn");
SetIndexLabel(3, "Short turn");
SetIndexLabel(4, "STC0");
SetIndexLabel(5, "STC1");
SetIndexLabel(6, "STC2");
SetIndexStyle(0, DRAW_ARROW);
SetIndexStyle(1, DRAW_ARROW);
SetIndexStyle(2, DRAW_ARROW);
SetIndexStyle(3, DRAW_ARROW);
SetIndexStyle(4, DRAW_LINE);
SetIndexStyle(5, DRAW_LINE);
SetIndexStyle(6, DRAW_LINE);
SetIndexArrow(0, markLongTrigger);
SetIndexArrow(1, markShortTrigger);
SetIndexArrow(2, markLongTurn);
SetIndexArrow(3, markShortTurn);
int n = MathMax(nFast, nSlow) + nStochas;
int n0 = n * timeFrame0 / Period();
int n1 = n * timeFrame1 / Period();
int n2 = n * timeFrame2 / Period();
int nMax = MathMax(MathMax(n0, n1), 2);
SetIndexDrawBegin(0, nMax); // 0: Long trigger
SetIndexDrawBegin(1, nMax); // 1: Short trigger
SetIndexDrawBegin(2, nMax); // 2: Long turn
SetIndexDrawBegin(3, nMax); // 3: Short turn
SetIndexDrawBegin(4, n0); // 4: STC, timeFrame0
SetIndexDrawBegin(5, n1); // 5: STC, timeFrame1
SetIndexDrawBegin(6, n2); // 6: STC, timeFrame2
SetLevelValue(0, levelLo);
SetLevelValue(1, levelHi);
}
//----------------------------------------------------------------------
void start()
{
int limit;
int counted_bars = IndicatorCounted();
if (counted_bars > 0) {
counted_bars--;
}
limit = Bars - counted_bars;
int limit0 = limit;
if (nMaxBars > 0) {
limit = MathMin(limit, nMaxBars);
}
// clear beyond limits
for (int i = limit0 - 1; i >= limit; i--) {
BufferLongTrigger[i] = EMPTY_VALUE; // 0: Long trigger
BufferShortTrigger[i] = EMPTY_VALUE; // 1: Short trigger
BufferLongTurn[i] = EMPTY_VALUE; // 2: Long turn
BufferShortTurn[i] = EMPTY_VALUE; // 3: Short turn
BufferSTC0[i] = EMPTY_VALUE; // 4: STC, timeFrame0
BufferSTC1[i] = EMPTY_VALUE; // 5: STC, timeFrame1
BufferSTC2[i] = EMPTY_VALUE; // 6: STC, timeFrame2
}
for (i = limit - 1; i >= 0; i--) {
int shift = iBarShift(NULL, timeFrame0, Time[i]);
// STC value
BufferSTC0[i] = iCustom(NULL, 0, sIndSTC, timeFrame0, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 0, shift);
BufferSTC1[i] = iCustom(NULL, 0, sIndSTC, timeFrame1, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 0, shift);
BufferSTC2[i] = iCustom(NULL, 0, sIndSTC, timeFrame2, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 0, shift);
// long turn
double bufLongTurn0 = iCustom(NULL, 0, sIndSTC, timeFrame0, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 3, shift);
double bufLongTurn1 = iCustom(NULL, 0, sIndSTC, timeFrame1, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 3, shift);
double bufLongTurn2 = iCustom(NULL, 0, sIndSTC, timeFrame2, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 3, shift);
// short turn
double bufShortTurn0 = iCustom(NULL, 0, sIndSTC, timeFrame0, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 4, shift);
double bufShortTurn1 = iCustom(NULL, 0, sIndSTC, timeFrame1, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 4, shift);
double bufShortTurn2 = iCustom(NULL, 0, sIndSTC, timeFrame2, nFast, nSlow, nStochas, bDoubleStochas, appliedPrice,
levelLo, levelHi, clearLo, clearHi, false, nMaxBars, 4, shift);
// check signal
bool bFire = false;
// long signal
bool bLong0 = (bufLongTurn0 != EMPTY_VALUE);
bool bLong1 = (bufLongTurn1 != EMPTY_VALUE);
bool bLong2 = (bufLongTurn2 != EMPTY_VALUE);
if (bLong0 && bLong1 && bLong2) {
if (BufferLongTrigger[i + 1] == EMPTY_VALUE && BufferLongTurn[i + 1] == EMPTY_VALUE) {
BufferLongTrigger[i] = LONG_MARK_POS;
bFire = true;
}
BufferLongTurn[i] = LONG_MARK_POS;
} else {
BufferLongTrigger[i] = EMPTY_VALUE;
BufferLongTurn[i] = EMPTY_VALUE;
}
// short signal
bool bShort0 = (bufShortTurn0 != EMPTY_VALUE);
bool bShort1 = (bufShortTurn1 != EMPTY_VALUE);
bool bShort2 = (bufShortTurn2 != EMPTY_VALUE);
if (bShort0 && bShort1 && bShort2) {
if (BufferShortTrigger[i + 1] == EMPTY_VALUE && BufferShortTurn[i + 1] == EMPTY_VALUE) {
BufferShortTrigger[i] = SHORT_MARK_POS;
bFire = true;
}
BufferShortTurn[i] = SHORT_MARK_POS;
} else {
BufferShortTrigger[i] = EMPTY_VALUE;
BufferShortTurn[i] = EMPTY_VALUE;
}
if (bAlert) {
if (i == 0 && bFire && tAlertLast != Time[0]) {
PlaySound("alert.wav");
tAlertLast = Time[0];
}
}
}
}
- 09-07-2018, 12:43 PM #3
المؤشر الثالث :
//
// "00-Sig-MultiSTC_v103.mq4" -- Schaff Trend Cycle
//
// Ver. 0.01 2008/10/30(Thu) initial version
// Ver. 1.00 2008/11/02(Sun) release version
// Ver. 1.03 2008/12/23(Tue) version sync
//
//
#property copyright "00 - [email protected]"
#property link "http://www.mql4.com/"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Crimson
#property indicator_width1 1
#property indicator_width2 1
//---- indicator parameters
/*extern*/ int nStopLossRange = 3; // draw S/L line in last N bars min/max
/*extern*/ int nBarAfterSignal = 10; // length of S/L line
//
/*extern*/ string sHelp0 = "--- params for "00-MultiSTC"";
/*extern*/ string sIndMultiSTC = "00-MultiSTC_v103"; // indicator name of "00-SidusV2"
extern int timeFrame0 = 0; // time frame 0
extern int timeFrame1 = 0; // time frame 1
extern int timeFrame2 = 0; // time frame 2
extern bool bAlert = false; // PlaySound() on signal
extern int nFast = 23; // EMA fast
extern int nSlow = 50; // EMA slow
extern int nStochas = 10; // Stochas period
extern bool bDoubleStochas = true; // apply stochas twice
extern int appliedPrice = PRICE_TYPICAL; // 0:CLOSE 1:OPEN 2:HIGH 3:LOW 4:MEDIAN 5:TYPICAL 6:WEIGHTED
extern double levelLo = 5; // lower threshold for long signal
extern double levelHi = 95; // upper threshold for short signal
extern double clearLo = 25; // lower level to clear long turn
extern double clearHi = 75; // upper level to clear short turn
extern int nMaxBars = 2000; // maximum number of bars to calculate, 0: no limit
/*extern*/ string sHelp1 = "--- end of params for "00-MultiSTC"";
//
/*extern*/ double point = 0.0; // point value
/*extern*/ color colLong = DodgerBlue; // color for long lines
/*extern*/ color colShort = Crimson; // color for short lines
//---- indicator buffers
double BufferLong[]; // 0: long signal
double BufferShort[]; // 2: short signal
//---- vars
string sIndicatorName = "00-Sig-SidusV2_v103";
string sPrefix;
int markLong = 233;
int markShort = 234;
datetime tAlertLast;
//----------------------------------------------------------------------
string TimeFrameToStr(int timeFrame)
{
switch (timeFrame) {
case 1: return("M1");
case 5: return("M5");
case 15: return("M15");
case 30: return("M30");
case 60: return("H1");
case 240: return("H4");
case 1440: return("D1");
case 10080: return("W1");
case 43200: return("MN");
}
return("??");
}
//----------------------------------------------------------------------
int NextPeriod(int timeFrame)
{
switch (timeFrame) {
case 1: return(5);
case 5: return(15);
case 15: return(30);
case 30: return(60);
case 60: return(240);
case 240: return(1440);
case 1440: return(10080);
case 10080: return(43200);
}
return(0);
}
//----------------------------------------------------------------------
void init()
{
if (timeFrame0 == 0 && timeFrame1 == 0 && timeFrame2 == 0) {
timeFrame0 = Period();
timeFrame1 = NextPeriod(timeFrame0);
timeFrame2 = NextPeriod(timeFrame1);
}
if (timeFrame0 == 0) {
timeFrame0 = Period();
}
if (timeFrame1 == 0) {
timeFrame1 = Period();
}
if (timeFrame2 == 0) {
timeFrame2 = Period();
}
sIndicatorName = (sIndMultiSTC + "(" +
TimeFrameToStr(timeFrame0) + "," +
TimeFrameToStr(timeFrame1) + "," +
TimeFrameToStr(timeFrame2) + ")");
sPrefix = sIndicatorName;
IndicatorShortName(sIndicatorName);
SetIndexBuffer(0, BufferLong);
SetIndexBuffer(1, BufferShort);
SetIndexLabel(0, "Long signal");
SetIndexLabel(1, "Short signal");
SetIndexStyle(0, DRAW_ARROW);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(0, markLong);
SetIndexArrow(1, markShort);
int n = MathMax(nFast, nSlow) + nStochas;
SetIndexDrawBegin(0, n);
SetIndexDrawBegin(1, n);
if (point == 0.0) {
point = Point;
}
}
//----------------------------------------------------------------------
void deinit()
{
int n = ObjectsTotal();
for (int i = n - 1; i >= 0; i--) {
string sName = ObjectName(i);
if (StringFind(sName, sPrefix) == 0) {
ObjectDelete(sName);
}
}
}
//----------------------------------------------------------------------
void objLine(string sName, datetime ts, double ps, datetime te, double pe, color col,
int width = 1, int style = STYLE_SOLID, bool bBack = true, bool bRay = false)
{
ObjectCreate(sName, OBJ_TREND, 0, 0, 0, 0);
ObjectSet(sName, OBJPROP_TIME1, ts);
ObjectSet(sName, OBJPROP_PRICE1, ps);
ObjectSet(sName, OBJPROP_TIME2, te);
ObjectSet(sName, OBJPROP_PRICE2, pe);
ObjectSet(sName, OBJPROP_COLOR, col);
ObjectSet(sName, OBJPROP_WIDTH, width);
ObjectSet(sName, OBJPROP_STYLE, style);
ObjectSet(sName, OBJPROP_BACK, bBack);
ObjectSet(sName, OBJPROP_RAY, bRay);
}
//----------------------------------------------------------------------
void start()
{
int limit;
int counted_bars = IndicatorCounted();
if (counted_bars > 0) {
counted_bars--;
}
limit = Bars - counted_bars;
int limit0 = limit;
if (nMaxBars > 0) {
limit = MathMin(limit, nMaxBars);
}
double ofst = 3 * point;
// clear beyond limits
for (int i = limit0 - 1; i >= limit; i--) {
BufferLong[i] = EMPTY_VALUE;
BufferShort[i] = EMPTY_VALUE;
}
for (i = limit - 1; i >= 0; i--) {
BufferLong[i] = EMPTY_VALUE;
BufferShort[i] = EMPTY_VALUE;
double bufLong = iCustom(NULL, 0, sIndMultiSTC, timeFrame0, timeFrame1, timeFrame2, false, nFast, nSlow, nStochas,
bDoubleStochas, appliedPrice, levelLo, levelHi, clearLo, clearHi, nMaxBars, 0, i);
double bufShort = iCustom(NULL, 0, sIndMultiSTC, timeFrame0, timeFrame1, timeFrame2, false, nFast, nSlow, nStochas,
bDoubleStochas, appliedPrice, levelLo, levelHi, clearLo, clearHi, nMaxBars, 1, i);
bool bLong = false;
bool bShort = false;
// long
if (bufLong != EMPTY_VALUE) {
bLong = true;
BufferLong[i] = Low[i] - ofst;
}
// short
if (bufShort != EMPTY_VALUE) {
bShort = true;
BufferShort[i] = High[i] + ofst;
}
bool bFire = (bLong || bShort);
if (bFire) {
if (nStopLossRange > 0) {
string sNameStopLossH = sPrefix + Time[i] + " SL H";
string sNameStopLossV = sPrefix + Time[i] + " SL V";
datetime t0 = Time[i];
datetime ts = Time[i + nStopLossRange];
datetime te = Time[i] + nBarAfterSignal * Period() * 60;
if (bLong) {
double p = Low[iLowest(NULL, 0, MODE_LOW, nStopLossRange, i + 1)];
objLine(sNameStopLossH, ts, p, te, p, colLong);
objLine(sNameStopLossV, t0, p, t0, p + 3 * Point, colLong);
} else {
p = High[iHighest(NULL, 0, MODE_HIGH, nStopLossRange, i + 1)];
objLine(sNameStopLossH, ts, p, te, p, colShort);
objLine(sNameStopLossV, t0, p, t0, p - 3 * Point, colShort);
}
}
if (bAlert) {
if (i == 0 && bFire && tAlertLast != Time[0]) {
PlaySound("alert.wav");
tAlertLast = Time[0];
}
}
}
}
WindowRedraw();
}
- 09-07-2018, 12:44 PM #4
صورة المؤشر بعد التركيب
مرفق الصوره لشكل المؤشر :
للاسف اصوره غير واضحه ولكن الخطوط متقطعه لذالك لا تظهر التقاطعات لمن يراها بشكل واضح .. ولكنها في الحقيقه تقاطعات ممتازه وتظهر في الميتاتريدر بشكل واضح وغير متقطع
- 09-07-2018, 01:48 PM #5
الحمدالله تم الحصول
حصلت ع المؤشر وحبيت اضعه لتعم الفائده للجميع ..
مرفق لكم المؤشر
- 10-07-2018, 03:34 PM #6