Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 972

 

//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict

double gdClose_array[1];

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
int x=Fr_sign();
Print(x);
}
//+------------------------------------------------------------------+

int Fr_sign()
{
int iX;
double dX=0;
int giResult=0;
iX=CopyClose(Symbol(),PERIOD_CURRENT,1,1,gdClose_array);
dX=gdClose_array[0];
Print ("dX ", dX);
dX=NormalizeDouble(gdClose_array[0],Digits);
Print ("NormalizeDouble(dX,Digits) ", dX);
return(0);
}
//+------------------------------------------------------------------+

As a result I get

2015.11.30 23:30:37.645 2015.10.30 22:54 111 EURUSD,H1: NormalizeDouble(dX,Digits) 1.05934

same value by test

 
Vinin:
You need at least three bars for a fractal
I must be coming from the wrong side. Any advice - here's a fractal on 1 bar. I need to compare its value with the values of the Bollinger lines to determine if the fractal is inside or outside. How can I represent this in the code?
 
Ha! Got it - you don't need fractals at all, at least not for my purposes. You have to compare the minimum or maximum price of the bar with the upper or lower value of the Bollinger lines, as a fractal has the value of the high or low of the bar on which it appeared. Right?
 

A fractal is the value of the high or low on 5 bars.

Having data on a single bar will not give you the correct fractal value.

 
n0name:

A fractal is the value of the high or low on 5 bars.

Having data on a single bar will not give you the correct fractal value.

Placing the "fractals" indicator on the chart, you will immediately see that the indicator arrows are positioned on the maximum or minimum bar, and their values are equal to the high or low of that bar. It does not matter how many bars the fractals are calculated on. Anyway, it is not important for my strategy.

Thanks anyway.

 
n0name:

...

as a result I get

2015.11.30 23:30:37.645 2015.10.30 22:54 111 EURUSD,H1: NormalizeDouble(dX,Digits) 1.05934

same value by test

A) To paste the code correctly here on the forum, click on SRC and then in the field that opens the code itself.


B) Try the following code.

#property strict

int OnInit()
  {
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   Fr_sign();
  }
//+------------------------------------------------------------------+

void Fr_sign()
  {
   double gdClose_array[1];
   if(CopyClose(_Symbol,PERIOD_CURRENT,1,1,gdClose_array)!=1) return;

   Print("Close price = ",DoubleToStr(gdClose_array[0],_Digits));
  }
 
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
   }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  Fr_sign();
  }
//+------------------------------------------------------------------+
 void Fr_sign()
  {
   double gdClose_array[1];
   if(CopyClose(_Symbol,PERIOD_CURRENT,1,1,gdClose_array)!=1) return;

   Print("Close price = ",DoubleToStr(gdClose_array[0],_Digits));
  }
//+------------------------------------------------------------------+ 

2015.12.01 22:24:01.683 2015.10.02 17:49 111 EURUSD,H1: Close price = 1.06181

2015.12.01 22:24:09.433 2015.11.27 10:04 111 EURUSD,H1: Close price = 1.06181

2015.12.01 22:24:09.701 2015.11.30 23:59 111 EURUSD,H1: Close price = 1.06181

tried on another pair

2015.12.01 22:35:58.830 2015.11.30 23:59 111 GBPUSD,H1: Close price = 1.50718

2015.12.01 22:35:58.683 2015.11.27 20:59 111 GBPUSD,H1: Close price = 1.50718

2015.12.01 22:35:50.434 2015.09.17 21:55 111 GBPUSD,H1: Close price = 1.50718

 
n0name:

2015.12.01 22:24:01.683 2015.10.02 17:49 111 EURUSD,H1: Close price = 1.06181

2015.12.01 22:24:09.433 2015.11.27 10:04 111 EURUSD,H1: Close price = 1.06181

2015.12.01 22:24:09.701 2015.11.30 23:59 111 EURUSD,H1: Close price = 1.06181

tried on another pair

2015.12.01 22:35:58.830 2015.11.30 23:59 111 GBPUSD,H1: Close price = 1.50718

2015.12.01 22:35:58.683 2015.11.27 20:59 111 GBPUSD,H1: Close price = 1.50718

2015.12.01 22:35:50.434 2015.09.17 21:55 111 GBPUSD,H1: Close price = 1.50718

Can't reproduce, it's not clear where the second date came from, I have this

2015.12.01 22:10:04.250 111 EURUSD,H1: Close price = 1.06336
2015.12.01 22:10:00.531 111 EURUSD,H1: Close price = 1.06336

2015.12.01 22:10:00.531 is the date and time;

111 - name of the Expert Advisor;

EURUSD,H1 - symbol name and timeframe;

Close price = 1.06336 - close price of candle with index 1 (the previous hour), so you will get it until the new hour arrives.

 
Mislaid:

Can't reproduce, it's not clear where the second date comes from, I have this

2015.12.01 22:10:04.250 111 EURUSD,H1: Close price = 1.06336
2015.12.01 22:10:00.531 111 EURUSD,H1: Close price = 1.06336

2015.12.01 22:10:00.531 is the date and time;

111 - name of the Expert Advisor;

EURUSD,H1 - symbol name and timeframe;

Close price = 1.06336 - closing price of candle with index 1 ( previous hour ), you will receive this until the new hour.

All correct, please do a test by selecting a few days. What will be the result?
 
n0name:
That's right, please do the test by selecting a few days. What will be the result?
I understand there is still a problem. Since my desire to help is still there and I somehow don't fully understand the problem, please write your expectations. The EA I wrote earlier will print the closing price of a candle with index 1 on every tick in the log. I put the EA on my M1 chart (not a history test) and it prints a new value when a new candle appears.
Reason: