lukas arrows and curves mtf + alerts

lukas arrows and curves mtf + alerts

更新日期:2022-09-14分类标签: 语言:中文平台:没限制

25 人已下载 手机查看

!!lukas arrows and curves mtf + alerts

//+——————————————————————+
//| lukas1 arrows & curves.mq4 v.14 |
//| Èçìåíåíèÿ: |
//| 1. Óáðàíû íåíóæíûå (ëèøíèå) êîýôôèöèåíû, íå ó÷àñòâóþùèå |
//| â ðàñ÷åòàõ Kmin, Kmax, RISK |
//| 2. Ìàòåìàòèêà èíäèêàòîðà âñå ðàñ÷åòû âûïîëíÿåò |
//| âíóòðè îäíîãî öèêëà, ýòî óâåëè÷èëî ñêîðîñòü îáñ÷¸òà. |
//| 3. Âûêëþ÷åíî ìåðöàíèå ñòðåëîê. |
//+——————————————————————+
#property copyright “Copyright © 2007, lukas1”
#property link “http://www.alpari-idc.ru/”
//—-
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Green

//
extern string TimeFrame = “Current time frame”;
extern int SSP = 6; //ïåðèîä ëèíåéíîãî ðàçâîðîòà èíäèêàòîðà
extern int SkyCh = 13; //÷óâñòâèòåëüíîñòü ê ïðîáîþ êàíàëà
input bool arrOnEverySig = true; // Arrows on every signal true/false?
extern bool ArrowOnFirst = true; // Arrow on first bars
extern bool alertsOn = true;
extern bool alertsOnCurrent = false;
extern bool alertsMessage = true;
extern bool alertsSound = true;
extern bool alertsEmail = false;
input bool alertsPushNotif = false; // Alerts push notification on/off?
input string soundFile = “alert2.wav”; // Sound file
extern bool Interpolate = true;

//
//
//
//
//

double val1[]; // áóôåð äëÿ áàé
double val2[]; // áóôåð äëÿ ñåëë
double Sky_BufferH[];
double Sky_BufferL[];
double trend[];
int timeFrame;
bool returnBars;
bool calculateValue;
string indicatorFileName;

//——————————————————————
//
//——————————————————————
//
//
//
//
//

int init()
{
IndicatorBuffers(5);
SetIndexBuffer(0, val1); SetIndexStyle(0, DRAW_ARROW); SetIndexArrow(0,233); SetIndexDrawBegin(0, 2*SSP);
SetIndexBuffer(1, val2); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1,234); SetIndexDrawBegin(1, 2*SSP);
SetIndexBuffer(2, Sky_BufferH); SetIndexLabel(2, “High”); SetIndexDrawBegin(2, 2*SSP);
SetIndexBuffer(3, Sky_BufferL); SetIndexLabel(3, “Low”); SetIndexDrawBegin(3, 2*SSP);
SetIndexBuffer(4, trend);
indicatorFileName = WindowExpertName();
calculateValue = TimeFrame==”calculateValue”; if (calculateValue) { return(0); }
returnBars = TimeFrame==”returnBars”; if (returnBars) { return(0); }
timeFrame = stringToTimeFrame(TimeFrame);
return(0);
}

//——————————————————————
//
//——————————————————————
//
//
//
//
//

//double work[][1];
//#define _uptrend 0

int start()
{
int i,counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars–;
int limit=MathMin(Bars-counted_bars,Bars-1);
if (returnBars) { val1[0] = limit; return(0); }

//
//
//
//
//

if (calculateValue || timeFrame == Period())
{
//GlobalVariableSet(“goSELL”, 0); // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè goSELL=0
// GlobalVariableSet(“goBUY”, 0); // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè goBUY =0
// if (ArrayRange(work,0)!=Bars) ArrayResize(work,Bars);

//
//
//
//
//

for(i = limit; i >=0; i–)
{
double rng = 0; for (int k=0; k<10 && (i+k)<Bars; k++) rng += High[i+k]-Low[i+k]; rng /= 10.0;
double high = High[ArrayMaximum(High,SSP,i)];
double low = Low[ArrayMinimum( Low,SSP,i)];
//double smax = high – (high – low)*SkyCh / 100;
//double smin = low + (high – low)*SkyCh / 100;
Sky_BufferH[i] = high – (high – low)*SkyCh / 100;
Sky_BufferL[i] = low + (high – low)*SkyCh / 100;
val1[i] = val2[i] = EMPTY_VALUE;
trend[i] = (i<Bars-1 && !arrOnEverySig) ? trend[i+1] : 0;
if (Close[i]>Sky_BufferH[i]) trend[i] = 1;
if (Close[i]<Sky_BufferL[i]) trend[i] =-1;
if (i<Bars-1 && trend[i]!=trend[i+1])
{
if (trend[i] == 1) val1[i] = Sky_BufferL[i];
if (trend[i] == -1) val2[i] = Sky_BufferH[i];
}

}
if (alertsOn)
{
int whichBar = 1; if (alertsOnCurrent) whichBar = 0;
if (trend[whichBar] != trend[whichBar+1])
{
if (trend[whichBar] == 1) doAlert(” up”);
if (trend[whichBar] ==-1) doAlert(” down”);
}
}
return(0);
}

//
//
//
//
//

int shift = -1; if (ArrowOnFirst) shift=1;
limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,”returnBars”,0,0)*timeFrame/Period()));
for (i=limit; i>=0; i–)
{
int y = iBarShift(NULL,timeFrame,Time[i]);
int z = iBarShift(NULL,timeFrame,Time[i+shift]);

Sky_BufferH[i] = iCustom(NULL,timeFrame,indicatorFileName,”calculateValue”,SSP,SkyCh,arrOnEverySig,ArrowOnFirst,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsPushNotif,soundFile,2,y);
Sky_BufferL[i] = iCustom(NULL,timeFrame,indicatorFileName,”calculateValue”,SSP,SkyCh,arrOnEverySig,ArrowOnFirst,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsPushNotif,soundFile,3,y);
val1[i] = EMPTY_VALUE;
val2[i] = EMPTY_VALUE;
if (y!=z)
{
val1[i] = iCustom(NULL,timeFrame,indicatorFileName,”calculateValue”,SSP,SkyCh,ArrowOnFirst,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsPushNotif,soundFile,0,y);
val2[i] = iCustom(NULL,timeFrame,indicatorFileName,”calculateValue”,SSP,SkyCh,ArrowOnFirst,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsPushNotif,soundFile,1,y);
}

//
//
//
//
//

if (!Interpolate || y==iBarShift(NULL,timeFrame,Time[i-1])) continue;

//
//
//
//
//

datetime time = iTime(NULL,timeFrame,y);
for(int n = 1; i+n < Bars && Time[i+n] >= time; n++) continue;
for(int j = 1; j < n; j++)
{
Sky_BufferH[i+j] = Sky_BufferH[i] + (Sky_BufferH[i+n] – Sky_BufferH[i])*j/n;
Sky_BufferL[i+j] = Sky_BufferL[i] + (Sky_BufferL[i+n] – Sky_BufferL[i])*j/n;
}
}
return(0);
}

//——————————————————————
//
//——————————————————————
//
//
//
//
//

void doAlert(string doWhat)
{
static string previousAlert=”nothing”;
static datetime previousTime;
string message;

if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];

//
//
//
//
//

message = timeFrameToString(_Period)+” “+_Symbol+” at “+TimeToStr(TimeLocal(),TIME_SECONDS)+” Lukas “+doWhat;
if (alertsMessage) Alert(message);
if (alertsPushNotif) SendNotification(message);
if (alertsEmail) SendMail(_Symbol+” Lukas “,message);
if (alertsSound) PlaySound(soundFile);
}
}

//——————————————————————-
//
//——————————————————————-
//
//
//
//
//

string sTfTable[] = {“M1″,”M5″,”M15″,”M30″,”H1″,”H4″,”D1″,”W1″,”MN”};
int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//
//
//
//
//

int stringToTimeFrame(string tfs)
{
tfs = stringUpperCase(tfs);
for (int i=ArraySize(iTfTable)-1; i>=0; i–)
if (tfs==sTfTable[i] || tfs==””+iTfTable[i]) return(MathMax(iTfTable[i],Period()));
return(Period());
}
string timeFrameToString(int tf)
{
for (int i=ArraySize(iTfTable)-1; i>=0; i–)
if (tf==iTfTable[i]) return(sTfTable[i]);
return(“”);
}

//
//
//
//
//

string stringUpperCase(string str)
{
string s = str;

for (int length=StringLen(str)-1; length>=0; length–)
{
int tchar = StringGetChar(s, length);
if((tchar > 96 && tchar < 123) || (tchar > 223 && tchar < 256))
s = StringSetChar(s, length, tchar – 32);
else if(tchar > -33 && tchar < 0)
s = StringSetChar(s, length, tchar + 224);
}
return(s);
}

如果你对文件有了解,请帮助投票!

If you are familiar with the file, please help vote!

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位投票人。

相关资源

暂无评论

暂无评论...