Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
VAZ2107U
//+------------------------------------------------------------------+
//| KAS721G Indicator v0.1 |
//| Copyright © 2008, Erik Dahlstrand |
//| http://www.dahlstrand.eu/ |
//| |
//| Indicator based on "KAS721G" by caireono |
//| http://forums.babypips.com/free-forex-trading-systems/ |
//| 11793-kas721g-trading-system.html |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Erik Dahlstrand"
#property link "http://www.dahlstrand.eu/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double validEntryLongBuffer[];
double validEntryShortBuffer[];
//---- input parameters
extern int entryArrowDisplacement = 6;
int init()
{
SetIndexArrow(0, SYMBOL_ARROWUP);
SetIndexBuffer(0, validEntryLongBuffer);
SetIndexEmptyValue(0, 0.0);
SetIndexLabel(0, "Go long");
SetIndexStyle(0, DRAW_ARROW, EMPTY, 3, Blue);
SetIndexArrow(1, SYMBOL_ARROWDOWN);
SetIndexBuffer(1, validEntryShortBuffer);
SetIndexEmptyValue(1, 0.0);
SetIndexLabel(1, "Go short");
SetIndexStyle(1, DRAW_ARROW, EMPTY, 3, Red);
Comment("KAS721G Indicator");
IndicatorShortName("KAS721G Indicator");
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int countedBars = IndicatorCounted();
int limit;
bool isMaCrossUp, isMaCrossDown;
double currentOpenPrice;
//---- indicators
double currentMA7, previousMA7; // Simple Moving Average (7)
double currentMA21, previousMA21; // Simple Moving Average (21)
double currentGHLA, previousGHLA; // Gann HiLo Activator
if(countedBars < 0) return(-1);
if(countedBars > 0) countedBars--;
limit = Bars - countedBars;
for(int i = 0; i < limit; i++)
{
currentMA7 = iMA(NULL, 0 , 7, 0, MODE_SMA, PRICE_CLOSE, i);
previousMA7 = iMA(NULL, 0 , 7, 0, MODE_SMA, PRICE_CLOSE, i + 1);
currentMA21 = iMA(NULL, 0 , 21, 0, MODE_SMA, PRICE_CLOSE, i);
previousMA21 = iMA(NULL, 0 , 21, 0, MODE_SMA, PRICE_CLOSE, i + 1);
currentGHLA = iCustom(NULL, 0, "Gann HiLo Activator", 2, i);
previousGHLA = iCustom(NULL, 0, "Gann HiLo Activator", 2, i + 1);
currentOpenPrice = Open[i];
isMaCrossUp = IsMaCrossUp(currentMA7, currentMA21, previousMA7, previousMA21);
isMaCrossDown = IsMaCrossDown(currentMA7, currentMA21, previousMA7, previousMA21);
if(isMaCrossUp && (currentGHLA > previousGHLA) && (currentGHLA < currentOpenPrice)) // I.e. upp trend
{
validEntryLongBuffer[i] = Low[i] - entryArrowDisplacement * Point;
if (i == 0) // Only notify on current bar
NotifyOnce("KAS721G indicator: GO LONG", "");
}
else if(isMaCrossDown && (currentGHLA < previousGHLA) && (currentGHLA > currentOpenPrice)) // I.e. down trend
{
validEntryShortBuffer[i] = High[i] + entryArrowDisplacement * Point;
if (i == 0) // Only notify on current bar
NotifyOnce("KAS721G indicator: GO SHORT", "");
}
}
return(0);
}
void NotifyOnce(string subject, string message)
{
static bool notified;
if (IsNewBar())
notified = false;
if (!notified)
{
SendMail(subject, message);
PlaySound("email.wav");
Print(subject);
notified = true;
}
}
bool IsMaCrossDown(double currentMA7, double currentMA21, double previousMA7, double previousMA21)
{
if ((currentMA7 < currentMA21) && (previousMA7 > previousMA21)) return (true);
return (false);
}
bool IsMaCrossUp(double currentMA7, double currentMA21, double previousMA7, double previousMA21)
{
if ((currentMA7 > currentMA21) && (previousMA7 < previousMA21)) return (true);
return (false);
}
bool IsNewBar()
{
static datetime previousDateTime;
datetime currentDateTime = Time[0];
if(previousDateTime != currentDateTime)
{
previousDateTime = currentDateTime;
return (true);
}
else
{
return (false);
}
}
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
---