Indicators with alerts/signal - page 1182

sara
301
sara  

Stochastic email alert

Can somebody help my providing an alert to my indicator stochastic?

Thanks in advance

sara
301
sara  

void CatchBullishDivergence(int shift)

{

if(IsIndicatorTrough(shift) == false)

return;

int currentTrough = shift;

int lastTrough = GetIndicatorLastTrough(shift);

//--CLASSIC DIVERGENCE--//

if (DisplayClassicalDivergences == true)

{

if(mainLine[currentTrough] > mainLine[lastTrough] && Low[currentTrough] < Low[lastTrough])

{

bullishDivergence[currentTrough] = mainLine[currentTrough] - arrowsDisplacement;

divergencesType[currentTrough] = 1; //"Classic Bullish";

divergencesStochasticsDiff[currentTrough] = MathAbs(mainLine[currentTrough] - mainLine[lastTrough]);

divergencesPriceDiff[currentTrough] = MathAbs(Low[currentTrough] - Low[lastTrough]);

if(drawPriceTrendLines == true)

DrawPriceTrendLine(Time[currentTrough], Time[lastTrough],

Low[currentTrough],

Low[lastTrough], Green, STYLE_SOLID);

if(drawIndicatorTrendLines == true)

DrawIndicatorTrendLine(Time[currentTrough],

Time[lastTrough],

mainLine[currentTrough],

mainLine[lastTrough],

Green, STYLE_SOLID);

if(displayAlert == true)

DisplayAlert("Classical Stochastics bullish divergence on: ", currentTrough);

}

}

//-----HIDDEN DIVERGENCE--//

if (DisplayHiddenDivergences == true)

{

if (mainLine[currentTrough] Low[lastTrough])

{

bullishDivergence[currentTrough] = mainLine[currentTrough] - arrowsDisplacement;

divergencesType[currentTrough] = 2; //"Hidden Bullish";

divergencesStochasticsDiff[currentTrough] = MathAbs(mainLine[currentTrough] - mainLine[lastTrough]);

divergencesPriceDiff[currentTrough] = MathAbs(Low[currentTrough] - Low[lastTrough]);

if(drawPriceTrendLines == true)

DrawPriceTrendLine(Time[currentTrough], Time[lastTrough],

Low[currentTrough],

Low[lastTrough], Green, STYLE_DOT);

if(drawIndicatorTrendLines == true)

DrawIndicatorTrendLine(Time[currentTrough],

Time[lastTrough],

mainLine[currentTrough],

mainLine[lastTrough],

Green, STYLE_DOT);

if(displayAlert == true)

DisplayAlert("Hidden Stochastics bullish divergence on: ", currentTrough);

}

}

}

void CatchBearishDivergence(int shift)

{

if(IsIndicatorPeak(shift) == false)

return;

int currentPeak = shift;

int lastPeak = GetIndicatorLastPeak(shift);

//-- CLASSIC DIVERGENCE --//

if (DisplayClassicalDivergences == true)

{

if(mainLine[currentPeak] High[lastPeak])

{

bearishDivergence[currentPeak] = mainLine[currentPeak] + arrowsDisplacement;

divergencesType[currentPeak] = 3; //"Classic Bearish";

divergencesStochasticsDiff[currentPeak] = MathAbs(mainLine[currentPeak] - mainLine[lastPeak]);

divergencesPriceDiff[currentPeak] = MathAbs(Low[currentPeak] - Low[lastPeak]);

if(drawPriceTrendLines == true)

DrawPriceTrendLine(Time[currentPeak], Time[lastPeak],

High[currentPeak],

High[lastPeak], Red, STYLE_SOLID);

if(drawIndicatorTrendLines == true)

DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak],

mainLine[currentPeak],

mainLine[lastPeak], Red, STYLE_SOLID);

if(displayAlert == true)

DisplayAlert("Classical Stochastics bearish divergence on: ", currentPeak);

}

}

//----HIDDEN DIVERGENCE----//

if (DisplayHiddenDivergences == true)

{

if(mainLine[currentPeak] > mainLine[lastPeak] && High[currentPeak] < High[lastPeak])

{

bearishDivergence[currentPeak] = mainLine[currentPeak] + arrowsDisplacement;

divergencesType[currentPeak] = 4;//"Hidden Bearish";

divergencesStochasticsDiff[currentPeak] = MathAbs(mainLine[currentPeak] - mainLine[lastPeak]);

divergencesPriceDiff[currentPeak] = MathAbs(Low[currentPeak] - Low[lastPeak]);

if(drawPriceTrendLines == true)

DrawPriceTrendLine(Time[currentPeak], Time[lastPeak],

High[currentPeak],

High[lastPeak], Red, STYLE_DOT);

if(drawIndicatorTrendLines == true)

DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak],

mainLine[currentPeak],

mainLine[lastPeak], Red, STYLE_DOT);

if(displayAlert == true)

DisplayAlert("Hidden Stochastics bearish divergence on: ", currentPeak);

}

}

}

bool IsIndicatorPeak(int shift)

{

if(mainLine[shift] >= mainLine[shift+1] && mainLine[shift] > mainLine[shift+2] && mainLine[shift] > mainLine[shift-1])

return(true);

else

return(false);

}

bool IsIndicatorTrough(int shift)

{

if(mainLine[shift] <= mainLine[shift+1] && mainLine[shift] < mainLine[shift+2] && mainLine[shift] < mainLine[shift-1])

return(true);

else

return(false);

}

int GetIndicatorLastPeak(int shift)

{

for(int i = shift + 5; i < Bars; i++)

{

if(mainLine >= mainLine && mainLine >= mainLine &&

mainLine >= mainLine && mainLine >= mainLine)

{

return(i);

}

}

return(-1);

}

int GetIndicatorLastTrough(int shift)

{

for(int i = shift + 5; i < Bars; i++)

{

if(mainLine <= mainLine && mainLine <= mainLine &&

mainLine <= mainLine && mainLine <= mainLine)

{

return(i);

}

}

return(-1);

}

void DisplayAlert(string message, int shift)

{

if(shift <= 2 && Time[shift] != lastAlertTime)

{

lastAlertTime = Time[shift];

Alert(message, Symbol(), " , ", Period(), " minutes chart");

}

}

void DrawPriceTrendLine(datetime x1, datetime x2, double y1, double y2, color lineColor, double style)

{

string label = "Stochastics_DivergenceLine_v1# " + DoubleToStr(x1, 0);

ObjectDelete(label);

ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(label, OBJPROP_RAY, 0);

ObjectSet(label, OBJPROP_COLOR, lineColor);

ObjectSet(label, OBJPROP_STYLE, style);

}

void DrawIndicatorTrendLine(datetime x1, datetime x2, double y1, double y2, color lineColor, double style)

{

int indicatorWindow = WindowFind(indicatorName);

if(indicatorWindow < 0)

return;

string label = "Stochastics_DivergenceLine_v1$# " + DoubleToStr(x1, 0);

ObjectDelete(label);

ObjectCreate(label, OBJ_TREND, indicatorWindow, x1, y1, x2, y2, 0, 0);

ObjectSet(label, OBJPROP_RAY, 0);

ObjectSet(label, OBJPROP_COLOR, lineColor);

ObjectSet(label, OBJPROP_STYLE, style);

Mladen Rakic
154659
Mladen Rakic  
pipsintheair:
void CatchBullishDivergence(int shift)

{

if(IsIndicatorTrough(shift) == false)

return;

int currentTrough = shift;

int lastTrough = GetIndicatorLastTrough(shift);

//--CLASSIC DIVERGENCE--//

if (DisplayClassicalDivergences == true)

{

if(mainLine[currentTrough] > mainLine[lastTrough] && Low[currentTrough] < Low[lastTrough])

{

bullishDivergence[currentTrough] = mainLine[currentTrough] - arrowsDisplacement;

divergencesType[currentTrough] = 1; //"Classic Bullish";

divergencesStochasticsDiff[currentTrough] = MathAbs(mainLine[currentTrough] - mainLine[lastTrough]);

divergencesPriceDiff[currentTrough] = MathAbs(Low[currentTrough] - Low[lastTrough]);

if(drawPriceTrendLines == true)

DrawPriceTrendLine(Time[currentTrough], Time[lastTrough],

Low[currentTrough],

Low[lastTrough], Green, STYLE_SOLID);

if(drawIndicatorTrendLines == true)

DrawIndicatorTrendLine(Time[currentTrough],

Time[lastTrough],

mainLine[currentTrough],

mainLine[lastTrough],

Green, STYLE_SOLID);

if(displayAlert == true)

DisplayAlert("Classical Stochastics bullish divergence on: ", currentTrough);

}

}

//-----HIDDEN DIVERGENCE--//

if (DisplayHiddenDivergences == true)

{

if (mainLine[currentTrough] Low[lastTrough])

{

bullishDivergence[currentTrough] = mainLine[currentTrough] - arrowsDisplacement;

divergencesType[currentTrough] = 2; //"Hidden Bullish";

divergencesStochasticsDiff[currentTrough] = MathAbs(mainLine[currentTrough] - mainLine[lastTrough]);

divergencesPriceDiff[currentTrough] = MathAbs(Low[currentTrough] - Low[lastTrough]);

if(drawPriceTrendLines == true)

DrawPriceTrendLine(Time[currentTrough], Time[lastTrough],

Low[currentTrough],

Low[lastTrough], Green, STYLE_DOT);

if(drawIndicatorTrendLines == true)

DrawIndicatorTrendLine(Time[currentTrough],

Time[lastTrough],

mainLine[currentTrough],

mainLine[lastTrough],

Green, STYLE_DOT);

if(displayAlert == true)

DisplayAlert("Hidden Stochastics bullish divergence on: ", currentTrough);

}

}

}

void CatchBearishDivergence(int shift)

{

if(IsIndicatorPeak(shift) == false)

return;

int currentPeak = shift;

int lastPeak = GetIndicatorLastPeak(shift);

//-- CLASSIC DIVERGENCE --//

if (DisplayClassicalDivergences == true)

{

if(mainLine[currentPeak] High[lastPeak])

{

bearishDivergence[currentPeak] = mainLine[currentPeak] + arrowsDisplacement;

divergencesType[currentPeak] = 3; //"Classic Bearish";

divergencesStochasticsDiff[currentPeak] = MathAbs(mainLine[currentPeak] - mainLine[lastPeak]);

divergencesPriceDiff[currentPeak] = MathAbs(Low[currentPeak] - Low[lastPeak]);

if(drawPriceTrendLines == true)

DrawPriceTrendLine(Time[currentPeak], Time[lastPeak],

High[currentPeak],

High[lastPeak], Red, STYLE_SOLID);

if(drawIndicatorTrendLines == true)

DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak],

mainLine[currentPeak],

mainLine[lastPeak], Red, STYLE_SOLID);

if(displayAlert == true)

DisplayAlert("Classical Stochastics bearish divergence on: ", currentPeak);

}

}

//----HIDDEN DIVERGENCE----//

if (DisplayHiddenDivergences == true)

{

if(mainLine[currentPeak] > mainLine[lastPeak] && High[currentPeak] < High[lastPeak])

{

bearishDivergence[currentPeak] = mainLine[currentPeak] + arrowsDisplacement;

divergencesType[currentPeak] = 4;//"Hidden Bearish";

divergencesStochasticsDiff[currentPeak] = MathAbs(mainLine[currentPeak] - mainLine[lastPeak]);

divergencesPriceDiff[currentPeak] = MathAbs(Low[currentPeak] - Low[lastPeak]);

if(drawPriceTrendLines == true)

DrawPriceTrendLine(Time[currentPeak], Time[lastPeak],

High[currentPeak],

High[lastPeak], Red, STYLE_DOT);

if(drawIndicatorTrendLines == true)

DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak],

mainLine[currentPeak],

mainLine[lastPeak], Red, STYLE_DOT);

if(displayAlert == true)

DisplayAlert("Hidden Stochastics bearish divergence on: ", currentPeak);

}

}

}

bool IsIndicatorPeak(int shift)

{

if(mainLine[shift] >= mainLine[shift+1] && mainLine[shift] > mainLine[shift+2] && mainLine[shift] > mainLine[shift-1])

return(true);

else

return(false);

}

bool IsIndicatorTrough(int shift)

{

if(mainLine[shift] <= mainLine[shift+1] && mainLine[shift] < mainLine[shift+2] && mainLine[shift] < mainLine[shift-1])

return(true);

else

return(false);

}

int GetIndicatorLastPeak(int shift)

{

for(int i = shift + 5; i < Bars; i++)

{

if(mainLine >= mainLine && mainLine >= mainLine &&

mainLine >= mainLine && mainLine >= mainLine)

{

return(i);

}

}

return(-1);

}

int GetIndicatorLastTrough(int shift)

{

for(int i = shift + 5; i < Bars; i++)

{

if(mainLine <= mainLine && mainLine <= mainLine &&

mainLine <= mainLine && mainLine <= mainLine)

{

return(i);

}

}

return(-1);

}

void DisplayAlert(string message, int shift)

{

if(shift <= 2 && Time[shift] != lastAlertTime)

{

lastAlertTime = Time[shift];

Alert(message, Symbol(), " , ", Period(), " minutes chart");

}

}

void DrawPriceTrendLine(datetime x1, datetime x2, double y1, double y2, color lineColor, double style)

{

string label = "Stochastics_DivergenceLine_v1# " + DoubleToStr(x1, 0);

ObjectDelete(label);

ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(label, OBJPROP_RAY, 0);

ObjectSet(label, OBJPROP_COLOR, lineColor);

ObjectSet(label, OBJPROP_STYLE, style);

}

void DrawIndicatorTrendLine(datetime x1, datetime x2, double y1, double y2, color lineColor, double style)

{

int indicatorWindow = WindowFind(indicatorName);

if(indicatorWindow < 0)

return;

string label = "Stochastics_DivergenceLine_v1$# " + DoubleToStr(x1, 0);

ObjectDelete(label);

ObjectCreate(label, OBJ_TREND, indicatorWindow, x1, y1, x2, y2, 0, 0);

ObjectSet(label, OBJPROP_RAY, 0);

ObjectSet(label, OBJPROP_COLOR, lineColor);

ObjectSet(label, OBJPROP_STYLE, style);

That is just the part of the indicator

If it does not work, how can we know if the error is not somewhere else?

nkcoghill
41
nkcoghill  

can someone add alerts to this, I know there are other adx crosses with alerts but I want this one. adxcrosses.mq4

Files:
Mladen Rakic
154659
Mladen Rakic  
nkcoghill:
can someone add alerts to this, I know there are other adx crosses with alerts but I want this one. adxcrosses.mq4

nkcoghill

That version of adx crosses is repainting (using future values)

Mladen Rakic
154659
Mladen Rakic  

Trix calculated the way how Jack K. Hutson described it (he invented it - a document with trix description can be found here : https://www.mql5.com/en/forum/179524 ) upgraded to be a bit more user friendly and some code changes : trix_log__alert__lines_3.mq4

nkcoghill
41
nkcoghill  

stochastic_mtfalerts_nmc.mq4 can someone please tell me the difference between the signal modes on this indicator. also is this indicator repainting?

nkcoghill
41
nkcoghill  
nkcoghill:
stochastic_mtfalerts_nmc.mq4 can someone please tell me the difference between the signal modes on this indicator. also is this indicator repainting?

Ok so Im pretty sure the signal modes are just the different MA types, but can someone tell me if its repainting?

Mladen Rakic
154659
Mladen Rakic  
nkcoghill:
Ok so Im pretty sure the signal modes are just the different MA types, but can someone tell me if its repainting?

Here is a version with descriptive names for time frame, signal mode and stochastic prices : stochastic_mtfalerts_2.mq4

__________________

PS: stochastic indicator do not repaint (no reason for it). But do not confuse multi time frame mode with repainting - multi time frame must update all the bars of the current time frame that bellong to the currently opened higher time frame opened bar(s)

Ricardo
110
Ricardo  

Mladen, Mrtools.

Can you please add alert to this indicator when all 4tf align, please.

kind regards

Ripefx

Files: