Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
StochCrossAlertOnClosedCandle
//+------------------------------------------------------------------+
//| StochCrossStrength.mq4 |
//| Copyright © 2006 Scorpion@fxfisherman.com |
//+------------------------------------------------------------------+
#property copyright "FxFisherman.com"
#property link "http://www.fxfisherman.com"
#property indicator_chart_window
#property indicator_buffers 1
#include <WinUser32.mqh>
extern string Sound1 = "alert.wav";
extern string Sound2 = "alert2.wav";
extern int Stoch_K = 5;
extern int Stoch_D = 3;
extern int Stoch_Slowing = 2;
//---- buffers
double v1[];
int init()
{
IndicatorBuffers(1);
SetIndexDrawBegin(0,-1);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Buy");
watermark();
return(0);
}
int start()
{
// Calculate values
double stochk0 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, 1);
double stochd0 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_SIGNAL, 1);
double stochk1 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, 2);
double stochd1 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_SIGNAL, 2);
int strength = 100 - (MathAbs(stochk0-stochd0)*5);
if (strength<0) strength=0;
// Output
static datetime last_cross;
if (last_cross != Time[0])
{
if (stochk1 <= stochd1 && stochk0 > stochd0)
{
last_cross = Time[0];
PlaySound(Sound1);
Alert(Symbol(), " ", Period(), " Stoch ", Stoch_K, ",", Stoch_D, ",", Stoch_Slowing, " Up");
//Alert("Stoch crosses up!");
}else if(stochk1 >= stochd1 && stochk0 < stochd0){
last_cross = Time[0];
PlaySound(Sound2);
Alert(Symbol(), " ", Period(), " Stoch ", Stoch_K, ",", Stoch_D, ",", Stoch_Slowing, " Dn");
//Alert("Stoch crosses down!");
}
}
return(0);
}
void watermark()
{
ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0);
ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", Black);
ObjectSet("fxfisherman", OBJPROP_CORNER, 2);
ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5);
ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10);
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---