You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
if(prev_calculated < 1) limit=MathMin(5000-1, rates_total-1-50);
:
return(rates_total);
I linked #7 to my post to do your look back correctly.
Once you fix #1, Fix look backs correctly.
Whroeder1 Thanks for your help, I do not understand how to write this code for the correct reading of the stroico.
for(int iBar = MathMax(lookback, prev_calculated; iBar < Bars; ++iBar){
// To access a Timeseries use index=Bars -1- iBar
// and convert any results back index=Bars -1- result
}
return rates_total-1; // Recalculate current bar next tick.
//Always count up so you're not using future values.
// buffer[i+2] has look back of 2 (as TimeSeries)
// buffer[i-2] has look back of 2 (not TimeSeries)
// use maximum of all.
Your code has a maximum of:
&& iOpen(Symbol(), PERIOD_CURRENT, 2+i) > iClose(Symbol(), PERIOD_CURRENT, 2+i)
&& iOpen(Symbol(), PERIOD_CURRENT, 3+i) > iClose(Symbol(), PERIOD_CURRENT, 3+i)
&& iOpen(Symbol(), PERIOD_CURRENT, 4+i) < iClose(Symbol(), PERIOD_CURRENT, 4+i);
I updated the code but nothing has changed
//| 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 limit = rates_total - prev_calculated;
int lookback= Buffer1[4];
//--- initial zero
//--- main loop
//for(int i = limit-1; i >= 0; i--)
for(int i = MathMax(lookback, prev_calculated); i < Bars; ++i)
{
double val;
int N;
bool Pattern = Open [1+i] > Close[ 1+i]
&& Open [2+i] > Close[ 2+i]
&& Open [3+i] > Close[ 3+i]
&& Open [4+i] < Close[ 4+i];
//Indicator Buffer 1
if( Pattern == true )
{
N = iHighest(NULL,0,MODE_CLOSE,6+i,4+i);
if(N!=-1) val = High[N];
else PrintFormat("Error in call iHighest. Error code=%d. Bars=%i start=%i",GetLastError(),Bars,4+i);
Buffer1[N] = val + 30*Point;
Print("Numero Candela: "+IntegerToString(N));
}
return(rates_total-1);
}
//+------------------------------------------------------------------+
I updated the code but nothing has changed
You need to be very precise when writing code.
WHRoeder's notes say:
It does not say:
___________________
I updated the code but nothing has changed
You have chosen to use WHRoeder's final example:
You cannot ignore the comments. WHRoeder rarely writes something without meaning.
I suggest you use this example instead, to avoid more confusion:
_____________________
You still need to fix this. It is wrong, as WHRoeder explained above:
I updated the code but nothing has changed
//| 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 limit = rates_total - prev_calculated;
int lookback = Buffer1[4];
ArraySetAsSeries(Buffer1, false);
for(int i = Bars-1-MathMax(lookback, prev_calculated); i >= 0; --i){
double val;
int N;
bool Pattern = Open [1+i] > Close[ 1+i]
&& Open [2+i] > Close[ 2+i]
&& Open [3+i] > Close[ 3+i]
&& Open [4+i] < Close[ 4+i];
//Indicator Buffer 1
if( Pattern == true )
{
N = iHighest(NULL,0,MODE_CLOSE,6+i,4+i);
if(N!=-1) val = High[N];
else PrintFormat("Error in call iHighest. Error code=%d. Bars=%i start=%i",GetLastError(),Bars,4+i);
Buffer1[N] = val + 30*Point;
Print("Numero Candela: "+IntegerToString(N));
}
return rates_total-1;
}
You have been told many times about
but you still do nothing about it.
What are you trying to do?
break it down using some different values for i
What does it do?
really thanks to everyone for the help ... I am a beginner and some concepts can not understand them. I added this code, but still we did not.
ArraySetAsSeries(Buffer1, false);
N = iHighest(NULL,0,MODE_CLOSE,6+i,4+i);
You seem to be ignoring most of the comment people give you. You can't do that. Your code will not work.
Hello everyone and thank you again for your comments. I did not understand what is the difference if I use "i" in candles or "i" in iHighest. I found another soluzuone which is fine for me.
//| 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 limit = rates_total - prev_calculated;
int lookback = Buffer1[4];
ArraySetAsSeries(Buffer1, true);
for(int i = Bars-1-MathMax(lookback, prev_calculated); i >= 0; --i){
bool Pattern = Open [1+i] > Close[ 1+i]
&& Open [2+i] > Close[ 2+i]
&& Open [3+i] > Close[ 3+i]
&& Open [4+i] < Close[ 4+i];
bool C4 = Close[4+i] > Close[5+i] && Close[4+i] > Close[6+i];
bool C5 = Close[5+i] > Close[4+i] && Close[5+i] > Close[6+i];
bool C6 = Close[6+i] > Close[4+i] && Close[6+i] > Close[5+i];
//Indicator Buffer 1
if( Pattern == true && C4 == true ) Buffer1[4+i] = High[4+i] + 30*Point;
if( Pattern == true && C5 == true ) Buffer1[5+i] = High[5+i] + 30*Point;
if( Pattern == true && C6 == true ) Buffer1[6+i] = High[6+i] + 30*Point;
}
return rates_total-1;
}
//+------------------------------------------------------------------+
There are still problems with your lookback, but if you're happy with how your code works, great!
I'd like to say I'm glad we helped, but I'm not entirely sure we did.