Questions from Beginners MQL5 MT5 MetaTrader 5 - page 877

 
It is possible thatUpper[i] is unfilled (equal to 0) on some bars.
 
Sergey Savinkin:
It's possible thatUpper[i] is not filled on some bars (equal to 0).

I think I've found some clue to the solution: when the condition is written against the current price state before running the code, the log outputs the following:

Important point - these parameters coincide with the price already generated earlier

To clarify:

This is where the last line of the log indicates that the price went beyond the Upper line. The only question is why did it do that? I have a version that during recalculation of indicator from the beginning to the present moment the code registers these events and stops at the last event - it explains the difference between price and current log data, but doesn't explain anything else - I need the code to make a simple comparison in logic "price went beyond upper line - give alert but nothing happens".

Also checked code condition when price is below upper line - it simply didn't record event in logs, which is on screenshot above - I stopped to understand it at the end, if it works at all.

 

My friends, I'm new to MQL5, so if the problems I'm writing about here are my own faults, please don't kick me too much.

I wanted to make a multicurrency owl, but faced some strange things in the strategy tester which appear only when testing multicurrency ones. I get some strange shifting of time-series symbols other than the main chart symbol. I have made a simple owl that gets zero and first bar open times by two symbols at the beginning of each bar. For some reason the second symbol timeseries starts shifting after 1 bar. Appears on any symbol and any timeframe. I was testing on EURUSD, the second symbol was GBPUSD. I've tried it vice versa, I've tried it on other pairs, the error always appears. This is the picture from the journal after testing on М15:

Log picture after testing on H1:

Strategy Tester settings:

Here is the code for the test:

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
input string SecondSymbol="GBPUSD";

int OnInit()
  {
   SymbolSelect(SecondSymbol,true);//выбираем второй символ в MarketWatch(для тестера)
//---
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
//---

  }

void OnTick()
  {
   static datetime BarTime;//время начала бара
   int per=PeriodSeconds(PERIOD_CURRENT);

   datetime time_curr=TimeCurrent()/per*per;
   if(time_curr!=BarTime)
     {
      BarTime=time_curr;

      datetime Time_One[],Time_Two[];
      bool yes=ArraySetAsSeries(Time_One,true);
      yes=ArraySetAsSeries(Time_Two,true);

      int i=CopyTime(NULL,PERIOD_CURRENT,0,2,Time_One);    //текущий символ
      i=CopyTime(SecondSymbol,PERIOD_CURRENT,0,2,Time_Two);//второй символ
      
      Print("ВремяНачалаБара по ",Symbol(),":",Time_One[0]," ВремяНачалаБара по ",SecondSymbol,":",Time_Two[0]);
     }
  }

Any help would be appreciated.

 
stroganow:

My friends, I'm new to MQL5, so if the problems I'm writing about here are my own faults, please don't kick me too much.

I wanted to make a multicurrency owl, but faced some strange things in the strategy tester which appear only when testing multicurrency ones. I get some strange shifting of time-series symbols other than the main chart symbol. I have made a simple owl that gets zero and first bar open times by two symbols at the beginning of each bar. For some reason the second symbol timeseries starts shifting after 1 bar. Appears on any symbol and any timeframe. I've been testing on EURUSD, the second symbol was GBPUSD. I've tried it vice versa, I've tried it on other pairs, the error always appears. This is the picture from the journal after testing on М15:

Log picture after testing on H1:

Strategy Tester settings:

The code for testing:

Any help would be appreciated.

The tester works correctly. There is an error in the program logic: Two symbols are like two lives of different people (here "person" is analogous to "symbol"). And the second person does not have to wake up at the same time as the first ("wake up" is analogous to " new bar appearing").

So you have to wait for a new bar to appear AND on the first symbol AND on the second.


Added: article "new bar" event handler

 

Can you tell me, here is a picture of a bullish pin bar, what should the principle code of the condition to recognise it look like?

if(low[i] <= open[i] && high[i] > close[i] && open[i] >= close[i] && close[i] <= Base[i]) // верно ли это утверждение?
 
clickaider:

Can you tell me, here is a picture of a bullish pin bar, what should the principle code of the condition to recognise it look like?

This is a bearish pin bar. The direction of the candle is not important. The position of the long shadow is important: up is bearish, down is bullish. And a confirmation from the level indicators is required.
 
Artyom Trishkin:
This is a bearish pin bar. The direction of the candle is not important. The position of the long shadow is important: up is bearish, down is bullish. And we need confirmation from the level indicators.
Can we show it by a code construction? It is just not quite clear how the code should look like
 
clickaider:
Is it possible to show this by code construction? It's just not quite clear how the code should look like
I can't write you the code from my mobile. At a glance:
You need the size of the candlestick from High Low, the size of the candlestick body, the percentage of the body to the size of the whole candlestick, the size of the short shadow should not exceed a certain threshold (so it was either absent or relatively small to the body), and the location of the top/bottom body relative to the full size of the candlestick.
Something like this...
 
Artyom Trishkin:
I can't write you the code from my mobile phone. At a glance:
You need the size of the candlestick from High Low, the size of the candlestick body, the percentage of the body to the size of the whole candlestick, the size of the short shadow should not exceed a certain threshold (so it was either absent or relatively small to the body), and the location of the top/bottom body relative to the full size of the candlestick.
Something like this...

Graphically it looks like this:

 
clickaider:

Graphically, it looks like this:

Now describe in words what you have described graphically. Use high, low, open, close.
Once you describe it in words, you've already written the ToR for yourself :)
All that remains is to replace the word constructions with code.