Questions from Beginners MQL5 MT5 MetaTrader 5 - page 654
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
The bar number of the lower fractal is known
From it, search in the loop for the first high corresponding to the low of the known fractal
We could do that, but I would do the opposite. I.e. first we find the high of the previous (formed) candle, and then the last fractal down. If they coincide, we put a point.
I don't understand. I thought that's what we were doing in the condition.
Enter LOGIN and PASSWORD from MQL5.community.
Where exactly is there one line?
Sorry, got confused with the terminal. Of course you only need to enter the LOGIN from MQL5.community.
I don't understand. I thought that's what we were doing in the condition.
Easy... do this...
#property link "https://www.mql5.com/ru/users/tapochun"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2
//---
#property indicator_type1 DRAW_ARROW
#property indicator_width1 5
#property indicator_color1 clrAqua
#property indicator_type2 DRAW_ARROW
#property indicator_width2 5
#property indicator_color2 clrRed
//+------------------------------------------------------------------+
//| Глобальные переменные |
//+------------------------------------------------------------------+
double bufSell[];
double bufBuy[];
//+------------------------------------------------------------------+
//| Входные параметры |
//+------------------------------------------------------------------+
input int inpNum=50; // Количество свечей для поиска последнего фрактала
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0,bufBuy);
SetIndexBuffer(1,bufSell);
SetIndexEmptyValue(0,EMPTY_VALUE);
SetIndexEmptyValue(1,EMPTY_VALUE);
SetIndexArrow(0,225);
SetIndexArrow(1,226);
IndicatorDigits(_Digits);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 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[])
{
if(rates_total<=0 || prev_calculated<0)
return( 0 );
//---
if(prev_calculated>0) // Если не первый расчет индикатора
{
}
else // Если первый расчет индикатора
{
ArrayInitialize(bufBuy,EMPTY_VALUE);
ArrayInitialize(bufSell,EMPTY_VALUE);
//---
for(int i=1; i<rates_total-7; i++)
{
CheckBuyArrow(low[i],i,i+4,rates_total-3,time);
CheckSellArrow(high[i],i,i+4,rates_total-3,time);
}
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CheckBuyArrow(const double price,
const int index,
const int first,
int last,
const datetime &time[]
)
{
last=(first+inpNum-1<last) ? first+inpNum-1 : last;
double iPrice;
//---
for(int i=first; i<=last; i++)
{
iPrice=iFractals(_Symbol,_Period,MODE_UPPER,i);
if(iPrice!=EMPTY_VALUE)
{
if(price==iPrice)
{
bufBuy[index]=iPrice-10*_Point;
Print(__FUNCTION__,": "+TimeToString(time[index])+" - "+TimeToString(time[i]));
}
return;
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CheckSellArrow(const double price,
const int index,
const int first,
int last,
const datetime &time[]
)
{
last=(first+inpNum-1<last) ? first+inpNum-1 : last;
double iPrice;
//---
for(int i=first; i<=last; i++)
{
iPrice=iFractals(_Symbol,_Period,MODE_LOWER,i);
if(iPrice!=EMPTY_VALUE)
{
if(price==iPrice)
{
bufSell[index]=iPrice+10*_Point;
Print(__FUNCTION__,": "+TimeToString(time[index])+" - "+TimeToString(time[i]));
}
return;
}
}
}
//+------------------------------------------------------------------+
Thanks, but it's not showing any signs of life...maybe I did something wrong?
Several options are possible:
Well the system is x64, because I have 8GB RAM, and the system win 10, ok thanks disconnected the firewall now try again !
I don't understand. I thought that's what we were doing in the condition.