bplturner
bplturner
Friends

Add friends via their profile or user search and you will be able to see if they are online

bplturner
Added topic Visual Backtest Reports Different Signals Once Stopped
Hello,   I am having a strange problem. I watch the visual backtest and look at the signals, then when I stop it new signals appear that weren't there during the visual backtest?  The ones that show once I stop are the right signals I want
bplturner
Added topic Custom Optimization
Hello,   I've Googled for tutorials but have been unable to find one.  I would like to use custom optimization to optimize by EA.  Specifically, I want to maximize profit/drawdown$ ratio to minimize risk.  Does anyone have an
bplturner
Added topic Open Trades Only During Certain Days
Hello,   I was wondering if anyone had any example code for opening trades during certain days.  I'd like to only open trades Sunday (when market opens) until Thursday.  If the trades are profitable by Friday, I'd like to close them
bplturner
Added topic iStdDevOnArray
Hello,  Is there any difference between   double dev = double   iStdDevOnArray( 0 , 0 , MODE_SMA , 0 , MA_LENGTH, i);  AND    double dev = double   iStdDevOnArray( 0 , MA_LENGTH, MODE_SMA , 0 , MA_LENGTH
bplturner
Added topic MQL4 iCustom Indicators Not Working in Backtesting
All,   I'm having a problem with iCustom indicators .  They work when I debug, and they work in live trading with a demo account, but when backtesting they return the EMPTY_VALUE or they return "0" when I SetIndexEmptyValue(0,0).  
ravibala
ravibala 2018.09.08
Hi bplturner, Iam also facing same problem with iCustom indicators. Iam using super trend indicator and Iam calling using ST2=iCustom(Symbol(),0,"SuperTrend",24,3.0,1,1). Could you pleasehelp me to share your ideas/experience in using iCustom functions. tx.

The codes for super trend is
//+------------------------------------------------------------------+
//| SuperTrend_03.mq4 |
//| Copyright 2014, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
// Different TimeFrame between chart & Super Trend Lines
// Begin 17 Nov 2014
#property copyright "Jay Ngui"
#property version "1.1"
#property strict

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+


#property indicator_chart_window
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_buffers 2

double TrendUp[], TrendDown[];
//int changeOfTrend;
extern int TimeFrame = 1440;
extern int NumPeriod = 10; //number of period
extern double Multiplier = 3;

//global variables
double UppBand[], LowBand[], SupTrPrice[];
datetime SupTrTime[];
datetime Time_0_Old = 0, Time_0_New;
int OnInit()
{
//---- indicators
SetIndexBuffer(0, TrendUp);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
SetIndexLabel(0, "Trend Up");
SetIndexBuffer(1, TrendDown);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
SetIndexLabel(1, "Trend Down");

//----
return(INIT_SUCCEEDED);
}

int deinit()
{


return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
//int OnCalculate(const int rates_total,
// const int prev_calculated,
// const datetime &time[],
// const double &open[],
// const double &high[],
// const double &low[],
// const double &close[],
// const long &tick_volume[],
// const long &volume[],
// const int &spread[])
// {
//---
int start()
{

int i, j, k;
int wBarLeft, wBarRight, wBarSupTr;
int wTimeFrame, wTimeFrame_Trend;
string wSym;
double wClose_0, wClose_1, wHigh_0, wLow_0;
datetime wTime;

wBarSupTr=0;
wSym=Symbol();
wTimeFrame=Period();
wBarLeft = Bars;
wBarRight = 0;
ArrayResize(UppBand,wBarLeft+2);
ArrayResize(LowBand,wBarLeft+2);
ArrayResize(TrendDown,wBarLeft+2);
ArrayResize(TrendUp,wBarLeft+2);
ArrayResize(SupTrPrice,wBarLeft+2);
ArrayResize(SupTrTime,wBarLeft+2);

wTimeFrame_Trend = TimeFrame;
//if (Trend_Same_As_Chart) wTimeFrame_Trend = wTimeFrame;

Time_0_New = iTime(wSym, wTimeFrame, 0);
if (Time_0_New != Time_0_Old)
{
//super trend array
fnSuperTrend_Array(wSym, wTimeFrame_Trend, wBarLeft, wBarRight, NumPeriod, Multiplier, SupTrPrice, SupTrTime,
UppBand, LowBand);

//draw super trend line
for (i=wBarLeft-1; i>=wBarRight; i--) // i refer chart
{
TrendUp[i] = EMPTY_VALUE;
TrendDown[i] = EMPTY_VALUE;
wTime = iTime(wSym, wTimeFrame, i);// time (bar) on chart
for (j=0; j SupTrTime[0])
{
wBarSupTr = 0;//
break;//exit j
}//end if (wTime > SupTrTime[0])
if ((wTime >= SupTrTime[j+1]) && (wTime < SupTrTime[j]))
{
wBarSupTr = j + 1;
break; //exit j
}//end if ((wTime = SupTrTime[j+1]))
}//end for (j=0; j= SupTrPrice[k]) TrendUp[i] = SupTrPrice[k];
if (wClose_0 SupTrPrice[k+1]) && (wClose_0 < SupTrPrice[k])) TrendDown[i+1] = SupTrPrice[k+1];
if ((wClose_1 SupTrPrice[k])) TrendUp[i+1] = SupTrPrice[k+1];
}//emd if ((wTime % TimeFrame) == 0)
}//end for (i=wBarLeft; i>=wBarRight; i--)[i-1];

WindowRedraw();
}//end if (Time_0_New != Time_0_Old)
Time_0_Old = Time_0_New;
return(0);
// return(rates_total);
}
//+------------------------------------------------------------------+
//***********************************************************************************


//******************************************************************
//------------------------------------------------------------------
//******************************************************************
//begin fnSuperTrend_Array()
void fnSuperTrend_Array(string wSym, int wTimeFrame, int wBarLeft, int wBarRight, int wNumPeriod, double wMultiplier,
double& wSupTrPrice[], datetime& wSupTrTime[], double& wUppBand[], double& wLowBand[])
{
int i;
double wHigh_t, wLow_t, wClose_t, wClose_tp, wATR;
double wTR, wUppBandB, wLowBandB;
datetime wTime_t;

for (i=wBarLeft; i>=wBarRight; i--)
{
wHigh_t=iHigh(wSym, wTimeFrame,i);
wLow_t=iLow(wSym,wTimeFrame,i);
wClose_t=iClose(wSym,wTimeFrame,i);
wClose_tp=iClose(wSym,wTimeFrame,i+1);
wTime_t=iTime(wSym,wTimeFrame,i);

//calculate True Range
wTR=(wHigh_t-wLow_t);
if (wClose_tp>wHigh_t) wTR=wClose_tp-wLow_t;
if (wClose_tp<wLow_t) wTR=wHigh_t-wClose_tp;

//calculate Average True Range
wATR = iATR(wSym, wTimeFrame,wNumPeriod,i);
//calculate Upper/Lower Band Basic
wUppBandB = (wHigh_t+wLow_t)/2 + wMultiplier*wATR;//Upper Band Basic
wLowBandB = (wHigh_t+wLow_t)/2 - wMultiplier*wATR;//Lowper Band Basic

//calculate Upper/Lower Band
wUppBand[i]=wUppBand[i+1];
if ((wUppBandB<wUppBand[i+1]) || (wUppBand[i+1]wLowBand[i+1]) || (wLowBand[i+1]>wClose_tp))
wLowBand[i]=wLowBandB;
//calculate SuperTrend
if (wSupTrPrice[i+1]==wUppBand[i+1])//Upper Band
{
wSupTrPrice[i]=wLowBand[i];
if (wClose_t=wLowBand[i])
wSupTrPrice[i]=wLowBand[i];
}//end if (wSupTr[i+1]=wUppBand[i+1])
wSupTrTime[i]=wTime_t;
}//end for (i=wBarLeft; i>wBarRight; i--)

}//end fnSuperTrend_Array()
//end fnSuperTrend_Array()
bplturner
Registered at MQL5.community
bplturner
Added topic Indicator on Indicator
Hello,   Is there an easy way to find the indicator of an indicator.  For instance, I'd like to take a simple moving average of the RSI and display that in it's own indicator.  Can something like that be done easily?  Any example