Dear coder, please add buffer value for buy and sell Arrow
So the indicator will have a total of 10 buffer
Here is the indicator
Thank your.
Inserted Code
extern color Arr_Up_col = clrLightCyan; extern color Arr_Dn_col = clrMagenta;
Here is the indicator
Inserted Code
//------------------------------------------------------------------
#property copyright "www.forex-tsd.com @ http://forexsystemsru.com/"
#property link "https://forexsystemsru.com/forums/indikatory-foreks.41/"
#property description "modified by Mobidik + Tankk"
//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 clrLightSteelBlue //LimeGreen
#property indicator_color2 clrMediumOrchid //Crimson //PaleVioletRed
#property indicator_color3 clrLightSteelBlue //LimeGreen
#property indicator_color4 clrMediumOrchid //Crimson //PaleVioletRed
#property indicator_color5 clrLightSteelBlue //LimeGreen
#property indicator_color6 clrMediumOrchid //Crimson //PaleVioletRed
#property indicator_color7 clrLightSteelBlue //LimeGreen
#property indicator_color8 clrMediumOrchid //Crimson //PaleVioletRed
#property indicator_minimum 0
#property indicator_maximum 5
//
//
//
//
//
extern int History = 3456;
extern ENUM_TIMEFRAMES AutoRefresh = PERIOD_M1;
extern string TimeFrame1 = "Current time frame";
extern string TimeFrame2 = "next1";
extern string TimeFrame3 = "next2";
extern string TimeFrame4 = "next3";
extern ENUM_MA_METHOD MaMethod1 = MODE_SMA;
extern ENUM_APPLIED_PRICE MaPrice1 = PRICE_CLOSE;
extern int MaPeriod1 = 1;
extern ENUM_MA_METHOD MaMethod2 = MODE_SMA;
extern int MaPeriod2 = 1;
extern bool UseHAHighLow = false;
extern string UniqueID = "4 TimeFrame MA Smooth";
extern int LinesWidth = 0;
extern color LabelsColor = clrAqua; //Orange; //DarkGray;
extern int LabelsHorizontalShift = 5;
extern double LabelsVerticalShift = 1.5;
extern bool All_Sig_Arrows = true;
extern color Arr_Up_col = clrLightCyan; //Lime;
extern color Arr_Dn_col = clrMagenta; //Red;
extern int Arr_otstup = 3;
extern int Arr_width = 1;
//extern bool alertsOn = false;
extern string soundFile = "alert2.wav"; //"news.wav"; //"expert.wav"; // //"stops.wav" //
extern int SIGNALBAR = 1; //На каком баре сигналить....
//extern int alertsLevel = 2;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsEmail = false;
extern bool alertsMobile = true;
//
//
//
//
//
double trends[], FLAG[];
double ha1u[];
double ha1d[];
double ha2u[];
double ha2d[];
double ha3u[];
double ha3d[];
double ha4u[];
double ha4d[];
//---
int timeFrames[4];
bool returnBars;
bool calculateValue;
string IndikName, uniqueID;
//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
int init()
{
IndicatorBuffers(10);
SetIndexBuffer(0,ha1u);
SetIndexBuffer(1,ha1d);
SetIndexBuffer(2,ha2u);
SetIndexBuffer(3,ha2d);
SetIndexBuffer(4,ha3u);
SetIndexBuffer(5,ha3d);
SetIndexBuffer(6,ha4u);
SetIndexBuffer(7,ha4d);
SetIndexBuffer(8,trends);
SetIndexBuffer(9,FLAG);
IndikName = WindowExpertName();
returnBars = (TimeFrame1=="returnBars"); if (returnBars) return(0);
calculateValue = (TimeFrame1=="calculateValue"); if (calculateValue) return(0);
//
//
uniqueID = UniqueID+" MS: ";
//
//
for (int i=0; i<8; i++)
{
SetIndexStyle(i,DRAW_ARROW,EMPTY,LinesWidth); SetIndexArrow(i,110);
}
timeFrames[0] = stringToTimeFrame(TimeFrame1);
timeFrames[1] = stringToTimeFrame(TimeFrame2);
timeFrames[2] = stringToTimeFrame(TimeFrame3);
timeFrames[3] = stringToTimeFrame(TimeFrame4);
IndicatorShortName(uniqueID);
return(0);
}
//------------------------------------------------------------------
//
//------------------------------------------------------------------
int deinit()
{
//for (int t=0; t<4; t++) ObjectDelete(UniqueID+t);
for (int i = ObjectsTotal()-1; i >= 0; i--)
if (StringSubstr(ObjectName(i), 0, StringLen(uniqueID)) == uniqueID)
ObjectDelete(ObjectName(i));
return(0);
}
//------------------------------------------------------------------
//
//------------------------------------------------------------------
datetime dtmPrevTime;
//---
bool blnNewBar(int TF)
{
if (dtmPrevTime==iTime(NULL,TF,0)) return(false);
dtmPrevTime=iTime(NULL,TF,0); return(true);
}
//------------------------------------------------------------------
//
//------------------------------------------------------------------
double trend[][2];
#define _up 0
#define _dn 1
//------------------------------------------------------------------
//------------------------------------------------------------------
int start()
{
if (IsConnected()) { if (!blnNewBar(AutoRefresh)) return(0); }
//---
int i,r,counted_bars=IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars>0) counted_bars--;
int limit = History;
if (limit <= fmax(MaPeriod1,MaPeriod2)) limit = fmin(Bars-counted_bars,Bars-1);
if (returnBars) { ha1u[0] = limit+1; return(0); }
if (calculateValue) { calculateHA(limit); return(0); }
if (timeFrames[0] != _Period) limit = fmax(limit,fmin(History,iCustom(NULL,timeFrames[0],IndikName,History,AutoRefresh,"returnBars",0,0,0)*timeFrames[0]/_Period));
if (timeFrames[1] != _Period) limit = fmax(limit,fmin(History,iCustom(NULL,timeFrames[1],IndikName,History,AutoRefresh,"returnBars",0,0,0)*timeFrames[1]/_Period));
if (timeFrames[2] != _Period) limit = fmax(limit,fmin(History,iCustom(NULL,timeFrames[2],IndikName,History,AutoRefresh,"returnBars",0,0,0)*timeFrames[2]/_Period));
if (timeFrames[3] != _Period) limit = fmax(limit,fmin(History,iCustom(NULL,timeFrames[3],IndikName,History,AutoRefresh,"returnBars",0,0,0)*timeFrames[3]/_Period));
if (ArrayRange(trend,0)!=Bars) ArrayResize(trend,Bars);
//
//
//
//
//
////static bool initialized = false;
////if (!initialized)
////{
//// initialized = true;
int window = WindowFind(uniqueID);
for (int t=0; t<4; t++)
{
string label = timeFrameToString(timeFrames[t]);
ObjectCreate(uniqueID+t,OBJ_TEXT,window,0,0);
ObjectSet(uniqueID+t,OBJPROP_COLOR,LabelsColor);
ObjectSet(uniqueID+t,OBJPROP_PRICE1,t+LabelsVerticalShift);
ObjectSet(uniqueID+t,OBJPROP_SELECTABLE,false);
ObjectSetText(uniqueID+t,label,8,"Arial");
}
////}
for (t=0; t<4; t++) ObjectSet(uniqueID+t,OBJPROP_TIME1,Time[0]+_Period*LabelsHorizontalShift*60);
//
//
//
//
//
for(i = limit, r=Bars-i-1; i >= 0; i--,r++)
{
trend[r][_up] = 0;
trend[r][_dn] = 0;
for (int k=0; k<4; k++)
{
int y = iBarShift(NULL,timeFrames[k],Time[i]);
if (UseHAHighLow)
{
double halo = iCustom(NULL,timeFrames[k],IndikName,History,AutoRefresh,"calculateValue","","","",MaMethod1,MaPrice1,MaPeriod1,MaMethod2,MaPeriod2,0,y);
double hahi = iCustom(NULL,timeFrames[k],IndikName,History,AutoRefresh,"calculateValue","","","",MaMethod1,MaPrice1,MaPeriod1,MaMethod2,MaPeriod2,1,y);
bool isUp = (hahi>halo);
}
else
{
double hacl = iCustom(NULL,timeFrames[k],IndikName,History,AutoRefresh,"calculateValue","","","",MaMethod1,MaPrice1,MaPeriod1,MaMethod2,MaPeriod2,2,y);
double haop = iCustom(NULL,timeFrames[k],IndikName,History,AutoRefresh,"calculateValue","","","",MaMethod1,MaPrice1,MaPeriod1,MaMethod2,MaPeriod2,3,y);
isUp = (haop>hacl);
}
//
//
//
//
//
switch (k)
{
case 0 : if (isUp) { ha1u[i] = k+1; ha1d[i] = EMPTY_VALUE;} else { ha1d[i] = k+1; ha1u[i] = EMPTY_VALUE; } break;
case 1 : if (isUp) { ha2u[i] = k+1; ha2d[i] = EMPTY_VALUE;} else { ha2d[i] = k+1; ha2u[i] = EMPTY_VALUE; } break;
case 2 : if (isUp) { ha3u[i] = k+1; ha3d[i] = EMPTY_VALUE;} else { ha3d[i] = k+1; ha3u[i] = EMPTY_VALUE; } break;
case 3 : if (isUp) { ha4u[i] = k+1; ha4d[i] = EMPTY_VALUE;} else { ha4d[i] = k+1; ha4u[i] = EMPTY_VALUE; } break;
}
if (isUp)
trend[r][_up] += 1;
else trend[r][_dn] += 1;
}
trends[i]=trends[i+1]; FLAG[i]=0;
if(trends[i]!=1 && ha1u[i]!=EMPTY_VALUE && ha2u[i]!=EMPTY_VALUE && ha3u[i]!=EMPTY_VALUE && ha4u[i]!=EMPTY_VALUE)
{
trends[i] = 1; FLAG[i] = 888;
arrows_wind(i,"Up",Arr_otstup ,233,Arr_Up_col,Arr_width,false);
}else{
ObjectDelete(uniqueID+"Up"+TimeToStr(Time[i]));
}
if(trends[i]!=-1 && ha1d[i]!=EMPTY_VALUE && ha2d[i]!=EMPTY_VALUE && ha3d[i]!=EMPTY_VALUE && ha4d[i]!=EMPTY_VALUE)
{
trends[i] =-1; FLAG[i] = -888;
arrows_wind(i,"Dn",Arr_otstup ,234,Arr_Dn_col,Arr_width,true);
}else{
ObjectDelete(uniqueID + "Dn" + TimeToStr(Time[i],TIME_DATE|TIME_SECONDS));
}
if(All_Sig_Arrows)
{
if(trends[i]== 1 && (ha1u[i]==EMPTY_VALUE || ha2u[i]==EMPTY_VALUE || ha3u[i]==EMPTY_VALUE || ha4u[i]==EMPTY_VALUE)) { trends[i] = 0; FLAG[i] = 444; }
if(trends[i]==-1 && (ha1d[i]==EMPTY_VALUE || ha2d[i]==EMPTY_VALUE || ha3d[i]==EMPTY_VALUE || ha4d[i]==EMPTY_VALUE)) { trends[i] = 0; FLAG[i] = -444; }
}
}
manageAlerts();
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void arrows_wind(int k, string N,int ots,int Code,color clr, int ArrowSize,bool up)
{
string objName = uniqueID+N+TimeToStr(Time[k]);
double gap=Arr_otstup*_Point; if (Digits==3 || Digits==5) gap*=10;
ObjectCreate(objName, OBJ_ARROW,0,Time[k],0);
ObjectSet (objName, OBJPROP_COLOR, clr);
ObjectSet (objName, OBJPROP_ARROWCODE,Code);
ObjectSet (objName, OBJPROP_WIDTH,ArrowSize);
ObjectSet (objName, OBJPROP_SELECTABLE,false);
if (up)
{
ObjectSet(objName, OBJPROP_ANCHOR,ANCHOR_BOTTOM);
ObjectSet(objName,OBJPROP_PRICE1,High[k]+gap);
}else{
ObjectSet(objName, OBJPROP_ANCHOR,ANCHOR_TOP);
ObjectSet(objName,OBJPROP_PRICE1,Low[k]-gap);
}
}
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//
void calculateHA(int limit)
{
for (int i=limit; i>=0; i--)
{
//double maOpen = iMA(NULL,0,MaPeriod1,0,MaMethod1,PRICE_OPEN ,i);
//double maClose = iMA(NULL,0,MaPeriod1,0,MaMethod1,PRICE_CLOSE,i);
//double maLow = iMA(NULL,0,MaPeriod1,0,MaMethod1,PRICE_LOW ,i);
//double maHigh = iMA(NULL,0,MaPeriod1,0,MaMethod1,PRICE_HIGH ,i);
//---
double haOpen = iMA(NULL,0,MaPeriod1,0,MaMethod1,MaPrice1,i+1); //(ha3u[i+1]+ha3d[i+1])/2.0;
double haClose = iMA(NULL,0,MaPeriod1,0,MaMethod1,MaPrice1,i); //(maOpen+maHigh+maLow+maClose)/4;
double haHigh = iMA(NULL,0,MaPeriod1,0,MaMethod1,PRICE_LOW,i); //fmax(maHigh, fmax(haOpen, haClose));
double haLow = iMA(NULL,0,MaPeriod1,0,MaMethod1,PRICE_HIGH,i); //fmin(maLow, fmin(haOpen, haClose));
if (haOpen<haClose)
{ ha4u[i]=haLow; ha4d[i]=haHigh; }
else { ha4d[i]=haLow; ha4u[i]=haHigh; }
ha3u[i]=haOpen;
ha3d[i]=haClose;
}
for(i=limit; i>=0; i--)
{
ha1u[i]=iMAOnArray(ha4u,0,MaPeriod2,0,MaMethod2,i);
ha1d[i]=iMAOnArray(ha4d,0,MaPeriod2,0,MaMethod2,i);
ha2u[i]=iMAOnArray(ha3u,0,MaPeriod2,0,MaMethod2,i);
ha2d[i]=iMAOnArray(ha3d,0,MaPeriod2,0,MaMethod2,i);
}
}
//
//
//
//
//
void manageAlerts()
{
if (FLAG[SIGNALBAR] > 0) doAlert("BUY");
if (FLAG[SIGNALBAR] < 0) doAlert("SELL");
//------
////if (alertsOn)
////{
//// int whichBar = Bars-1;
//// if (trend[whichBar][_up] >= alertsLevel || trend[whichBar][_dn] >= alertsLevel)
//// {
//// if (trend[whichBar][_up] >= alertsLevel) doAlert("BUY",trend[whichBar][_up]);
//// if (trend[whichBar][_dn] >= alertsLevel) doAlert("SELL",trend[whichBar][_dn]);
//// }
////}
}
//
//
//
//
//
void doAlert(string doWhat) ///, int howMany)
{
static string previousAlert="nothing";
static datetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];
//
//
//
//
//
message = "4 TimeFrame MA Smooth MS: "+_Symbol+", "+stringMTF(_Period)+": Arrow for "+doWhat; ///Symbol()+" at "+TimeToStr(TimeLocal(),TIME_SECONDS)+" "+howMany+" time frames of haDelta are aligned "+doWhat;
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(_Symbol,message);
if (alertsMobile) SendNotification(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 toInt(double value) { return(value); }
int stringToTimeFrame(string tfs)
{
tfs = stringUpperCase(tfs);
int max = ArraySize(iTfTable)-1, add=0;
int nxt = (StringFind(tfs,"NEXT1")>-1); if (nxt>0) { tfs = ""+_Period; add=1; }
nxt = (StringFind(tfs,"NEXT2")>-1); if (nxt>0) { tfs = ""+_Period; add=2; }
nxt = (StringFind(tfs,"NEXT3")>-1); if (nxt>0) { tfs = ""+_Period; add=3; }
//
//
//
//
//
for (int i=max; i>=0; i--)
if (tfs==sTfTable[i] || tfs==""+iTfTable[i]) return(fmax(iTfTable[toInt(fmin(max,i+add))],_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);
}
string stringMTF(int perMTF)
{
if (perMTF==0) perMTF=_Period;
if (perMTF==1) return("M1");
if (perMTF==5) return("M5");
if (perMTF==15) return("M15");
if (perMTF==30) return("M30");
if (perMTF==60) return("H1");
if (perMTF==240) return("H4");
if (perMTF==1440) return("D1");
if (perMTF==10080) return("W1");
if (perMTF==43200) return("MN1");
if (perMTF== 2 || 3 || 4 || 6 || 7 || 8 || 9 || /// нестандартные периоды для грфиков Renko
10 || 11 || 12 || 13 || 14 || 16 || 17 || 18) return("M"+(string)_Period);
//------
return("Ошибка периода");
}
//**************************************************************************//
//*** 3 MA VZO HD AA MTF ANT+TT ***
//**************************************************************************//