/* Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] Website: http://purebeam.biz E-mail : purebeam@gmail.com Modified by Robert to use same variable names as sidus_v3_alerts */ #property copyright "safe" #property link "http://www.metaquotes.net/" #property indicator_chart_window #property indicator_buffers 4 // First 2 buffers are MAs #property indicator_color1 Black #property indicator_color2 Black #property indicator_color3 Blue #property indicator_color4 Red #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 2 extern int FastEMA = 14; extern int SlowEMA = 21; // Added from sidus extern string ex = "0=SMA,1=EMA,2=SSMA,3=LWMA"; extern int mamode = MODE_EMA; // sidus uses LWMA extern string ex2 = "0=Close,1=Open,2=High,3=Low"; extern string ex2a = "4=Median,5=Typical,6=Weighted"; extern int maprice = PRICE_CLOSE; extern int RSIPeriod = 17; extern bool Alerts = FALSE; extern bool EmailOn = false; extern int ArrowOffset = 5; double FastMA_Buffer[]; double SlowMA_Buffer[]; double UpArrowBuffer[]; double DownArrowBuffer[]; // sidus uses an additional buffer int trend = 0; int trend_prev = 0; double diff = 0.0; // sidus declars this in start function double myPoint; // this handles 5 digit pricing correctly int init() { SetIndexStyle(0, DRAW_NONE); // Do not show MA SetIndexBuffer(0, FastMA_Buffer); SetIndexStyle(1, DRAW_NONE); // do not show MA SetIndexBuffer(1, SlowMA_Buffer); SetIndexStyle(2, DRAW_ARROW, STYLE_DASH); SetIndexArrow(2, 233); SetIndexBuffer(2, UpArrowBuffer); SetIndexEmptyValue(2, 0.0); SetIndexStyle(3, DRAW_ARROW, STYLE_DASH); SetIndexArrow(3, 234); SetIndexBuffer(3, DownArrowBuffer); SetIndexEmptyValue(3, 0.0); myPoint = SetPoint(); return (0); } int deinit() { return (0); } int start() { int counted_bars = IndicatorCounted(); double rsi = 0; bool trend_change = FALSE; double price = 0; if (counted_bars < 0) return (-1); if (counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; if (limit < 5) limit = 5; for (int i = limit; i >= 0; i--) { // FastMA_Buffer[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i); // SlowMA_Buffer[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i); FastMA_Buffer[i] = iMA(NULL, 0, FastEMA, 0, mamode, maprice, i); SlowMA_Buffer[i] = iMA(NULL, 0, SlowEMA, 0, mamode, maprice, i); rsi = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i); diff = FastMA_Buffer[i] - SlowMA_Buffer[i]; Comment("pipdiffCurrent = " + diff + " "); if (diff > 0.0 && rsi > 50.0) trend = 1; else if (diff < 0.0 && rsi < 50.0) trend = 2; // sidus uses -1 for down trend if (trend == 1 && trend_prev == 2) { // sidus compares trend[i] != trend[i+1] : same idea here // sidus uses FastMA_Buffer and atr(20) instead of High or Low and 5 * Point DownArrowBuffer[i] = High[i] + ArrowOffset * myPoint; // was - 5 * Point trend_change = TRUE; price = Ask; } else { if (trend == 2 && trend_prev == 1) { UpArrowBuffer[i] = Low[i] - ArrowOffset * myPoint; trend_change = TRUE; price = Bid; } } trend_prev = trend; } // sidus uses differernt method to do alerts if (Alerts && trend_change) { PlaySound("alert.wav"); if (trend_prev == 1) { MessageBox("Entry point: buy at " + price + "!!", "Entry Point", 0); if (EmailOn) SendMail("Safe Alert","Entry point: buy at " + price + "!!"); } else if (trend_prev == 2) { MessageBox("Entry point: sell at " + price + "!!", "Entry Point", 0); if (EmailOn) SendMail("Safe Alert","Entry point: sell at " + price + "!!"); } trend_change = FALSE; } RefreshRates(); return (0); } double SetPoint() { double mPoint; if (Digits < 4) mPoint = 0.01; else mPoint = 0.0001; return(mPoint); }