Re: Coding Help

924
I tried using this indicator in timeframe mode but it couldn't, could someone help me;;;;;




#property indicator_chart_window
#property indicator_buffers 14
#property indicator_color1 Green
#property indicator_color2 DeepSkyBlue
#property indicator_color3 PaleVioletRed
#property indicator_color4 PaleVioletRed
#property indicator_color5 DeepSkyBlue
#property indicator_color6 PaleVioletRed
#property indicator_color7 PaleVioletRed
#property indicator_color8 PaleVioletRed
#property indicator_color9 DeepSkyBlue
#property indicator_color10 PaleVioletRed
#property indicator_color11 PaleVioletRed
//
//
//
//
//
extern string TimeFrame = "current time frame";
extern int BandsLength = 20;
extern double BandsDeviation = 2.0;
extern int BandsShift = 0;
extern int AppliedPrice = PRICE_CLOSE;
extern bool MultiColor = true;
extern bool alertsOn = true;
extern bool alertsOnUpperBandSlope = true;
extern bool alertsOnLowerBandSlope = false;
extern bool alertsOnCurrent = true;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsNotify = false;
extern bool alertsEmail = false;

//
//
//
//
//

double ma[];
double upBDa[];
double upBDb[];
double upBand[];
double dnBDa[];
double dnBDb[];
double dnBand[];
double slope1[];
double slope2[];
double tBuffer[][4];


string indicatorFileName;
bool returnBars;
int timeFrame;

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
SetIndexBuffer(0,ma);
SetIndexBuffer(1,upBand);
SetIndexBuffer(2,upBDa);
SetIndexBuffer(3,upBDb);
SetIndexBuffer(4,dnBand);
SetIndexBuffer(5,dnBDa);
SetIndexBuffer(6,dnBDb);
SetIndexBuffer(7,slope1);
SetIndexBuffer(8,slope2);


SetIndexShift(0,BandsShift);
SetIndexShift(1,BandsShift);
SetIndexShift(2,BandsShift);
SetIndexShift(3,BandsShift);
SetIndexShift(4,BandsShift);
SetIndexShift(5,BandsShift);
SetIndexShift(6,BandsShift);
SetIndexShift(7,BandsShift);
SetIndexShift(8,BandsShift);

IndicatorShortName("bollinger bands ");
returnBars = TimeFrame=="returnBars"; if (returnBars) { return(0); }
timeFrame = stringToTimeFrame(TimeFrame);

IndicatorShortName(timeFrameToString(timeFrame)+" bollinger bands ");
return(0);
}

//
//
//
//
//

int deinit() { return(0); }

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

#define iMt1 0
#define iMt2 1
#define iUt1 2
#define iUt2 3

//
//
//
//
//

int start()
{
int counted_bars=IndicatorCounted();
int limit,i,r;

if(counted_bars < 0) return(-1);
if(counted_bars>0) counted_bars--;
limit=MathMin(Bars-1,Bars-counted_bars);
if (ArrayRange(tBuffer,0) != Bars) ArrayResize(tBuffer,Bars);
if (ArrayRange(slope1,0)!=Bars) ArrayResize(slope1,Bars);
if (ArrayRange(slope2,0)!=Bars) ArrayResize(slope2,Bars);

//
//
//
//
//
if (timeFrame == Period())
{
double alpha = 2.0/(BandsLength+1.0);

if (MultiColor && slope1[limit]==-1) CleanPoint(limit,upBDa,upBDb);
if (MultiColor && slope2[limit]==-1) CleanPoint(limit,dnBDa,dnBDb);
for (i=limit, r=Bars-i-1; i>=0; i--,r++)
{
double price = iMA(NULL,0,BandsLength,0,MODE_SMA,AppliedPrice,i);
double dt2=iStdDev(NULL,0,BandsLength,0,MODE_SMA,PRICE_CLOSE,i);
//
//
//
//
//



//
//
//
//
//

ma = price;
upBand = ma+BandsDeviation*dt2;
dnBand = ma-BandsDeviation*dt2;
upBDa = EMPTY_VALUE;
upBDb = EMPTY_VALUE;
dnBDa = EMPTY_VALUE;
dnBDb = EMPTY_VALUE;
slope1[r] = slope1[r-1];
slope2[r] = slope2[r-1];

if (upBand < upBand[i+1]) slope1[r] =-1;
if (upBand[i] > upBand[i+1]) slope1[r] = 1;
if (dnBand[i] < dnBand[i+1]) slope2[r] =-1;
if (dnBand[i] > dnBand[i+1]) slope2[r] = 1;
if (MultiColor && slope1[r] == -1) PlotPoint(i,upBDa,upBDb,upBand);
if (MultiColor && slope2[r] == -1) PlotPoint(i,dnBDa,dnBDb,dnBand);

}
manageAlerts();
return(0);
}

//
//


limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));
if (MultiColor && slope1[r] == -1) CleanPoint(limit,upBDa,upBDb);
if (MultiColor && slope2[r] == -1) CleanPoint(limit,dnBDa,dnBDb);
for(i=limit; i>=0; i--)
{
int y = iBarShift(NULL,timeFrame,Time[i]);
ma[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,0,y);


upBand[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,3,y);
upBDa[i] = EMPTY_VALUE;
upBDb[i] = EMPTY_VALUE;

dnBand[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,4,y);
dnBDa[i] = EMPTY_VALUE;
upBDa[i] = EMPTY_VALUE;
slope1[r] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,7,y);
slope2[r] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,8,y);

if (MultiColor && slope1[r] == -1) PlotPoint(i,upBDa,upBDb,upBand);
if (MultiColor && slope2[r] == -1) PlotPoint(i,dnBDa,dnBDb,dnBand);
}



return(0);
}

//
//
//

void CleanPoint(int i,double& first[],double& second[])
{
if ((second[i] != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
second[i+1] = EMPTY_VALUE;
else
if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
first[i+1] = EMPTY_VALUE;
}

//
//
//
//
//

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
if (first[i+1] == EMPTY_VALUE)
{
if (first[i+2] == EMPTY_VALUE) {
first[i] = from[i];
first[i+1] = from[i+1];
second[i] = EMPTY_VALUE;
}
else {
second[i] = from[i];
second[i+1] = from[i+1];
first[i] = EMPTY_VALUE;
}
}
else
{
first[i] = from[i];
second[i] = EMPTY_VALUE;
}
}

//+-------------------------------------------------------------------
//|
//+-------------------------------------------------------------------
//
//
//
//
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)
{
StringToUpper(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("");
}
//

void manageAlerts()
{
if (alertsOn)
{
if (alertsOnCurrent)
int whichBar = 0;
else whichBar = 1; whichBar = iBarShift(NULL,0,iTime(NULL,0,whichBar));
whichBar = Bars-whichBar-1;

//
//
//
//
//

static datetime time1 = 0;
static string mess1 = "";
if (alertsOnUpperBandSlope && slope1[whichBar] != slope1[whichBar-1])
{
if (slope1[whichBar] == 1) doAlert(time1,mess1,whichBar,"Upper Band sloping up");
if (slope1[whichBar] == -1) doAlert(time1,mess1,whichBar,"Upper Band sloping down");
}

static datetime time2 = 0;
static string mess2 = "";
if (alertsOnLowerBandSlope && slope2[whichBar] != slope2[whichBar-1])
{
if (slope2[whichBar] == 1) doAlert(time2,mess2,whichBar,"Lower Band sloping up");
if (slope2[whichBar] == -1) doAlert(time2,mess2,whichBar,"Lower Band sloping down");
}

}
}

//
//
//
//
//

void doAlert(datetime& previousTime, string& previousAlert, int forBar, string doWhat)
{
string message;

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

//
//
//
//
//

message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Better Bollinger Bands ",doWhat);
if (alertsMessage) Alert(message);
if (alertsNotify) SendNotification(StringConcatenate(Symbol(), Period() ," Better Bollinger Bands " +" "+message));
if (alertsEmail) SendMail(StringConcatenate(Symbol()," Better Bollinger Bands "),message);
if (alertsSound) PlaySound("alert2.wav");
}
}

Re: Coding Help

925
denicalcio wrote: Sun Feb 03, 2019 10:43 pm I tried using this indicator in timeframe mode but it couldn't, could someone help me;;;;;




#property indicator_chart_window
#property indicator_buffers 14
#property indicator_color1 Green
#property indicator_color2 DeepSkyBlue
#property indicator_color3 PaleVioletRed
#property indicator_color4 PaleVioletRed
#property indicator_color5 DeepSkyBlue
#property indicator_color6 PaleVioletRed
#property indicator_color7 PaleVioletRed
#property indicator_color8 PaleVioletRed
#property indicator_color9 DeepSkyBlue
#property indicator_color10 PaleVioletRed
#property indicator_color11 PaleVioletRed
//
//
//
//
//
extern string TimeFrame = "current time frame";
extern int BandsLength = 20;
extern double BandsDeviation = 2.0;
extern int BandsShift = 0;
extern int AppliedPrice = PRICE_CLOSE;
extern bool MultiColor = true;
extern bool alertsOn = true;
extern bool alertsOnUpperBandSlope = true;
extern bool alertsOnLowerBandSlope = false;
extern bool alertsOnCurrent = true;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsNotify = false;
extern bool alertsEmail = false;

//
//
//
//
//

double ma[];
double upBDa[];
double upBDb[];
double upBand[];
double dnBDa[];
double dnBDb[];
double dnBand[];
double slope1[];
double slope2[];
double tBuffer[][4];


string indicatorFileName;
bool returnBars;
int timeFrame;

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
SetIndexBuffer(0,ma);
SetIndexBuffer(1,upBand);
SetIndexBuffer(2,upBDa);
SetIndexBuffer(3,upBDb);
SetIndexBuffer(4,dnBand);
SetIndexBuffer(5,dnBDa);
SetIndexBuffer(6,dnBDb);
SetIndexBuffer(7,slope1);
SetIndexBuffer(8,slope2);


SetIndexShift(0,BandsShift);
SetIndexShift(1,BandsShift);
SetIndexShift(2,BandsShift);
SetIndexShift(3,BandsShift);
SetIndexShift(4,BandsShift);
SetIndexShift(5,BandsShift);
SetIndexShift(6,BandsShift);
SetIndexShift(7,BandsShift);
SetIndexShift(8,BandsShift);

IndicatorShortName("bollinger bands ");
returnBars = TimeFrame=="returnBars"; if (returnBars) { return(0); }
timeFrame = stringToTimeFrame(TimeFrame);

IndicatorShortName(timeFrameToString(timeFrame)+" bollinger bands ");
return(0);
}

//
//
//
//
//

int deinit() { return(0); }

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

#define iMt1 0
#define iMt2 1
#define iUt1 2
#define iUt2 3

//
//
//
//
//

int start()
{
int counted_bars=IndicatorCounted();
int limit,i,r;

if(counted_bars < 0) return(-1);
if(counted_bars>0) counted_bars--;
limit=MathMin(Bars-1,Bars-counted_bars);
if (ArrayRange(tBuffer,0) != Bars) ArrayResize(tBuffer,Bars);
if (ArrayRange(slope1,0)!=Bars) ArrayResize(slope1,Bars);
if (ArrayRange(slope2,0)!=Bars) ArrayResize(slope2,Bars);

//
//
//
//
//
if (timeFrame == Period())
{
double alpha = 2.0/(BandsLength+1.0);

if (MultiColor && slope1[limit]==-1) CleanPoint(limit,upBDa,upBDb);
if (MultiColor && slope2[limit]==-1) CleanPoint(limit,dnBDa,dnBDb);
for (i=limit, r=Bars-i-1; i>=0; i--,r++)
{
double price = iMA(NULL,0,BandsLength,0,MODE_SMA,AppliedPrice,i);
double dt2=iStdDev(NULL,0,BandsLength,0,MODE_SMA,PRICE_CLOSE,i);
//
//
//
//
//



//
//
//
//
//

ma = price;
upBand = ma+BandsDeviation*dt2;
dnBand = ma-BandsDeviation*dt2;
upBDa = EMPTY_VALUE;
upBDb = EMPTY_VALUE;
dnBDa = EMPTY_VALUE;
dnBDb = EMPTY_VALUE;
slope1[r] = slope1[r-1];
slope2[r] = slope2[r-1];

if (upBand < upBand[i+1]) slope1[r] =-1;
if (upBand[i] > upBand[i+1]) slope1[r] = 1;
if (dnBand[i] < dnBand[i+1]) slope2[r] =-1;
if (dnBand[i] > dnBand[i+1]) slope2[r] = 1;
if (MultiColor && slope1[r] == -1) PlotPoint(i,upBDa,upBDb,upBand);
if (MultiColor && slope2[r] == -1) PlotPoint(i,dnBDa,dnBDb,dnBand);

}
manageAlerts();
return(0);
}

//
//


limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));
if (MultiColor && slope1[r] == -1) CleanPoint(limit,upBDa,upBDb);
if (MultiColor && slope2[r] == -1) CleanPoint(limit,dnBDa,dnBDb);
for(i=limit; i>=0; i--)
{
int y = iBarShift(NULL,timeFrame,Time[i]);
ma[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,0,y);


upBand[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,3,y);
upBDa[i] = EMPTY_VALUE;
upBDb[i] = EMPTY_VALUE;

dnBand[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,4,y);
dnBDa[i] = EMPTY_VALUE;
upBDa[i] = EMPTY_VALUE;
slope1[r] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,7,y);
slope2[r] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",BandsLength,BandsDeviation,AppliedPrice,8,y);

if (MultiColor && slope1[r] == -1) PlotPoint(i,upBDa,upBDb,upBand);
if (MultiColor && slope2[r] == -1) PlotPoint(i,dnBDa,dnBDb,dnBand);
}



return(0);
}

//
//
//

void CleanPoint(int i,double& first[],double& second[])
{
if ((second[i] != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
second[i+1] = EMPTY_VALUE;
else
if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
first[i+1] = EMPTY_VALUE;
}

//
//
//
//
//

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
if (first[i+1] == EMPTY_VALUE)
{
if (first[i+2] == EMPTY_VALUE) {
first[i] = from[i];
first[i+1] = from[i+1];
second[i] = EMPTY_VALUE;
}
else {
second[i] = from[i];
second[i+1] = from[i+1];
first[i] = EMPTY_VALUE;
}
}
else
{
first[i] = from[i];
second[i] = EMPTY_VALUE;
}
}

//+-------------------------------------------------------------------
//|
//+-------------------------------------------------------------------
//
//
//
//
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)
{
StringToUpper(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("");
}
//

void manageAlerts()
{
if (alertsOn)
{
if (alertsOnCurrent)
int whichBar = 0;
else whichBar = 1; whichBar = iBarShift(NULL,0,iTime(NULL,0,whichBar));
whichBar = Bars-whichBar-1;

//
//
//
//
//

static datetime time1 = 0;
static string mess1 = "";
if (alertsOnUpperBandSlope && slope1[whichBar] != slope1[whichBar-1])
{
if (slope1[whichBar] == 1) doAlert(time1,mess1,whichBar,"Upper Band sloping up");
if (slope1[whichBar] == -1) doAlert(time1,mess1,whichBar,"Upper Band sloping down");
}

static datetime time2 = 0;
static string mess2 = "";
if (alertsOnLowerBandSlope && slope2[whichBar] != slope2[whichBar-1])
{
if (slope2[whichBar] == 1) doAlert(time2,mess2,whichBar,"Lower Band sloping up");
if (slope2[whichBar] == -1) doAlert(time2,mess2,whichBar,"Lower Band sloping down");
}

}
}

//
//
//
//
//

void doAlert(datetime& previousTime, string& previousAlert, int forBar, string doWhat)
{
string message;

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

//
//
//
//
//

message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Better Bollinger Bands ",doWhat);
if (alertsMessage) Alert(message);
if (alertsNotify) SendNotification(StringConcatenate(Symbol(), Period() ," Better Bollinger Bands " +" "+message));
if (alertsEmail) SendMail(StringConcatenate(Symbol()," Better Bollinger Bands "),message);
if (alertsSound) PlaySound("alert2.wav");
}
}


Not sure what was being attempted because it was part better bollinger band and regular bollinger band, so did it as a regular one.
These users thanked the author mrtools for the post:
denicalcio


Re: Coding Help

926
mntiwana wrote: Wed Jan 23, 2019 5:48 am
"iExposure_Tickets v1.0.9+.mod"
Dont know what exact you are looking for - often round queries like this are over looked because of peoples busy life era,as a result when some thing posted by rough guess,is replied and responded as i dont asked for this and or this do not help me - so the poster became ashamed rather than happy to help,do not we think and feel as we are facing and know the matter/issue in context,others can not notice it the way,mind reading is really a matter for all of us - :)
dont take it personal,it is for all of us
any way posting here one of (Paul Geirnaerdhist) code,already posted by bilbao
Thanks that's exactly what I was looking for.

Re: Coding Help

927
mrtools & mladen
I would like to use this indicator in an EA so could you tell me the buffers for the 1 & -1 that would be useful. I tried the buffers explorer 2 but its not working.

need buffer numbers: Do we have a new buffer indentifier this isn't working : Also I get this comment for " Averages Channel Candles + alerts 2.07"
comment about the name??? comment about the name???
Thank you
Ray

Re: Coding Help

928
traderduke wrote: Thu Feb 07, 2019 12:47 am mrtools & mladen
I would like to use this indicator in an EA so could you tell me the buffers for the 1 & -1 that would be useful. I tried the buffers explorer 2 but its not working.

need buffer numbers: Averages Channel Candles + alerts 2.07.ex4

Do we have a new buffer indentifier this isn't working : Buffers explorer 2.mq4

Also I get this comment for " Averages Channel Candles + alerts 2.07"
2-6-2019 8-58-37 AM-acc-name.png

Thank you
Ray
You are missing one "s" in the name (alerts not alert)

Re: Coding Help

929
mladen wrote: Thu Feb 07, 2019 3:24 am

You are missing one "s" in the name (alerts not alert)

mladen, Thanks and its good to hear from you. I'm not sure how that happened , I have it loaded on several platforms but ony happened this one time.
Any info about the 1 or -1 buffer numbers or a buffer explorer that can identify them.

Thanks again
Ray

Re: Coding Help

930
mladen wrote: Thu Feb 07, 2019 3:24 am

You are missing one "s" in the name (alerts not alert)
Hi mladen
I got the buffer explorer working, my mistake. Five trends, you have out done yourself. I'm writing the EA as we speak.
I was wondering if I could get a less involved version of the ACC v2.07 with the source code. I'm trying to add the function to a dashboard. The indicator needs some added coded to perform & signal the dashboard.

Thank you for your interest
Ray


Who is online

Users browsing this forum: Amazon [Bot] and 18 guests