.

Coding help ...

Moderators: mntiwana, mrtools



Re: Coding help ...

#922
Hi, I have Renko EA, which generates offline Renko chart. I am working on my own indicator and what I would like to do is call iCustom function from my indicator on this EA without having to actually generate the Renko chart. Something like this:

iCustom(Symbol,NULL,"Renko",0,100,true,1);

I would like to read last 20 Renko bars. Is this even possible?

Re: Coding help ...

#923
I'll try using this thread to get these indicators fixed.......
They work individually but not together - which is what is required.
Can a coder look at them and get them to work together please?
Thanks
TEAMTRADER
Trading_Volume_v1 -13.mq4
(10.87 KiB) Downloaded 81 times
Trading_Volume_v1.mq4
(10.86 KiB) Downloaded 74 times

Re: Coding help ...

#924
TEAMTRADER wrote:
Fri Feb 01, 2019 11:40 pm
I'll try using this thread to get these indicators fixed.......
They work individually but not together - which is what is required.
Can a coder look at them and get them to work together please?
Thanks
TEAMTRADER
Cant you manage code unique ID within any of one
Indicator is just a tool.

Use it only if it can benefit you. Leave it if you don't know how to use it optimally.

Re: Coding help ...

#925
mntiwana wrote:
Fri Feb 01, 2019 11:47 pm
TEAMTRADER wrote:
Fri Feb 01, 2019 11:40 pm
I'll try using this thread to get these indicators fixed.......
They work individually but not together - which is what is required.
Can a coder look at them and get them to work together please?
Thanks
TEAMTRADER
Cant you manage code unique ID within any of one
There is no unique code - that is what makes it impossible for me to fix.
TEAMTRADER


Re: Coding help ...

#927
pacois wrote:
Sat Feb 02, 2019 1:07 am
TEAMTRADER wrote:
Sat Feb 02, 2019 12:21 am

There is no unique code - that is what makes it impossible for me to fix.
TEAMTRADER
Thank you - most appreciated.
TEAMTRADER

Re: Coding help ...

#928
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 ...

#929
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.
bollinger band.mq4
(7.23 KiB) Downloaded 80 times

Re: Coding help ...

#930
mntiwana wrote:
Wed Jan 23, 2019 5:48 am
traderduke wrote:
Wed Jan 23, 2019 5:21 am
mntiwana
Do you or anyone else reminder a indicator that keeps track of an (entry/buy/sell) as to its high or low and a rolling total of all.

Thanks for your help
Ray
"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.



Who is online

Users browsing this forum: CommonCrawl [Bot] and 1 guest