Questions from Beginners MQL5 MT5 MetaTrader 5 - page 704

 
Comments not related to this topic have been moved to "Where can I download a proper MT4? Without the online installer.".
 

The Expert Advisor has the following code (long after a rising candle, close position after a falling candle):

         if (Close[1]>Open[1])
                 {
                     printf("Сигнал на покупку");
                     trade.Buy(1);
                  }
         if (PositionsTotal()>0 && Close[1]<Open[1]) trade.PositionClose(Symbol());

trade - objectof CTrade class

Many trades are executed (in the tester). But some deals are executed at unrealistic prices.

For example, at the current price 131540, maximal candle 131630, we buy at the price 134570.

Log entry:

2016.12.18 05:27:03.086 Core 1 2013.04.22 10:01:00 Buy signal

2016.12.18 05:27:03.086 Core 1 2013.04.22 10:01:00 exchange buy 1.00 RTS-6.13 at 134570 (131540 / 134570 / 131540)

2016.12.18 05:27:03.086 Core 1 2013.04.22 10:01:00 deal #6 buy 1.00 RTS-6.13 at 134570 done (based on order #6)

2016.12.18 05:27:03.086 Core 1 2013.04.22 10:01:00 deal performed [#6 buy 1.00 RTS-6.13 at 134570]

2016.12.18 05:27:03.087 Core 1 2013.04.22 10:01:00 order performed buy 1.00 at 134570 [#6 buy 1.00 RTS-6.13 at 134570]

2016.12.18 05:27:03.087 Core 1 2013.04.22 10:01:00 CTrade::OrderSend: exchange buy 1.00 RTS-6.13 [done]


Why does this happen? Where does the left price (134570 in this case) come from? The vast majority of trades are at normal prices, but one out of 20-30 trades is at some left-hand prices. On the chart such deals are also displayed well above the candle.

 
dimnik:

The Expert Advisor has the following code (long after a rising candle, close position after a falling candle):

         if (Close[1]>Open[1])
                 {
                     printf("Сигнал на покупку");
                     trade.Buy(1);
                  }
         if (PositionsTotal()>0 && Close[1]<Open[1]) trade.PositionClose(Symbol());

trade - objectof CTrade class

Many trades are executed (in the tester). But some deals are executed at unrealistic prices.

For example, at the current price 131540, maximal candle 131630, we buy at the price 134570.

Log entries:

2016.12.18 05:27:03.086 Core 1 2013.04.22 10:01:00 Buy signal

2016.12.18 05:27:03.086 Core 1 2013.04.22 10:01:00 exchange buy 1.00 RTS-6.13 at 134570 (131540 / 134570 / 131540)

2016.12.18 05:27:03.086 Core 1 2013.04.22 10:01:00 deal #6 buy 1.00 RTS-6.13 at 134570 done (based on order #6)

2016.12.18 05:27:03.086 Core 1 2013.04.22 10:01:00 deal performed [#6 buy 1.00 RTS-6.13 at 134570]

2016.12.18 05:27:03.087 Core 1 2013.04.22 10:01:00 order performed buy 1.00 at 134570 [#6 buy 1.00 RTS-6.13 at 134570]

2016.12.18 05:27:03.087 Core 1 2013.04.22 10:01:00 CTrade::OrderSend: exchange buy 1.00 RTS-6.13 [done]


Why does this happen? Where does the left price (134570 in this case) come from? The vast majority of trades are at normal prices, but one out of 20-30 trades is at some left-hand prices. On the chart such deals are also displayed well above the candle.

Turn on the ask price display. Because purchases are opened at ask price, and candlesticks stand at bid price.
 
Sergey Gritsay:
Switch on the ask price display. Because purchases are opened at ask price and candlesticks are at bid price.
How? And what does ask have to do with it, if it's not even close to that on the history?
 
dimnik:
How? And what does ask have to do with it if the quotes were not even close to that on the story?

Are you sure? Is the server demo or real? Have you unpunched the tick history from 10:00:30 to 10:01:30?

Added:

Although I doubt the correctness of the history, which is TRY years old:

2016.12.18 05:27:03.086 Core 1  2013.04.22 10:01:00   Сигнал на покупку
2016.12.18 05:27:03.086 Core 1  2013.04.22 10:01:00   exchange buy 1.00 RTS-6.13 at 134570 (131540 / 134570 / 131540)
2016.12.18 05:27:03.086 Core 1  2013.04.22 10:01:00   deal #6 buy 1.00 RTS-6.13 at 134570 done (based on order #6)
2016.12.18 05:27:03.086 Core 1  2013.04.22 10:01:00   deal performed [#6 buy 1.00 RTS-6.13 at 134570]
2016.12.18 05:27:03.087 Core 1  2013.04.22 10:01:00   order performed buy 1.00 at 134570 [#6 buy 1.00 RTS-6.13 at 134570]
2016.12.18 05:27:03.087 Core 1  2013.04.22 10:01:00   CTrade::OrderSend: exchange buy 1.00 RTS-6.13 [done]
 

Hi all. Can you please tell me what is wrong here?

double RedLine = iCustom(Symbol(), 0, Forexofftrend3, CountBars, SSP, Kmin, Kmax, 0, 0);

When compiling, it writes Forexofftrend3 - undeclared identifier.

And so with any invoked indicator.

Files:
RSI.JPG  94 kb
RSI0.JPG  34 kb
 
Сергей:

Hi all. Can you please tell me what is wrong here?

double RedLine = iCustom (Symbol(), 0, Forexofftrend3, CountBars, SSP, Kmin, Kmax, 0, 0);

When compiling, it writes Forexofftrend3 - undeclared identifier.

And so with any invoked indicator.

double RedLine =  iCustom (Symbol(), 0, " Forexofftrend3", CountBars, SSP, Kmin, Kmax, 0, 0);
 
@Vitaly Muzichenko, thank you for your prompt reply.
 
Sergey Gritsay:
Turn on the ask price display. Because purchases are opened at ask price and candlesticks stand at bid price.

You were right.

I did the ask price - it is higher by 3030 pips than bid/ask.

And on most of the history it is 10 pips (the real price step of this instrument), but on some of the history it goes up to 3030 pips (at 18:44 in the underscore).

How do we change that?

GE      0       13:13:23.758    Core 1  2013.04.19 18:43:57   Last 128967.000000 Bid 128967.000000 Ask 128997.000000
FJ      0       13:13:23.758    Core 1  2013.04.19 18:43:57   Last 128966.000000 Bid 128966.000000 Ask 128996.000000
CO      0       13:13:23.758    Core 1  2013.04.19 18:43:57   Last 128967.000000 Bid 128967.000000 Ask 128997.000000
CL      0       13:13:23.758    Core 1  2013.04.19 18:43:58   Last 128966.000000 Bid 128966.000000 Ask 128996.000000
OQ      0       13:13:23.758    Core 1  2013.04.19 18:43:58   Last 128968.000000 Bid 128968.000000 Ask 128998.000000
HF      0       13:13:23.758    Core 1  2013.04.19 18:43:58   Last 128967.000000 Bid 128967.000000 Ask 128997.000000
KK      0       13:13:23.758    Core 1  2013.04.19 18:43:58   Last 128968.000000 Bid 128968.000000 Ask 128998.000000
LO      0       13:13:23.758    Core 1  2013.04.19 18:43:58   Last 128967.000000 Bid 128967.000000 Ask 128997.000000
GL      0       13:13:23.758    Core 1  2013.04.19 18:43:58   Last 128968.000000 Bid 128968.000000 Ask 128998.000000
OQ      0       13:13:23.758    Core 1  2013.04.19 18:43:59   Last 128967.000000 Bid 128967.000000 Ask 128997.000000
DF      0       13:13:23.758    Core 1  2013.04.19 18:43:59   Last 128968.000000 Bid 128968.000000 Ask 128998.000000
CK      0       13:13:23.758    Core 1  2013.04.19 18:43:59   Last 128967.000000 Bid 128967.000000 Ask 128997.000000
GH      0       13:13:23.758    Core 1  2013.04.19 18:43:59   Last 128970.000000 Bid 128970.000000 Ask 129000.000000
FM      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128970.000000 Bid 128970.000000 Ask 132000.000000
CR      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128971.000000 Bid 128971.000000 Ask 132001.000000
RF      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128970.000000 Bid 128970.000000 Ask 132000.000000
OK      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128971.000000 Bid 128971.000000 Ask 132001.000000
NH      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128970.000000 Bid 128970.000000 Ask 132000.000000
NM      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128972.000000 Bid 128972.000000 Ask 132002.000000
IR      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128971.000000 Bid 128971.000000 Ask 132001.000000
JG      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128972.000000 Bid 128972.000000 Ask 132002.000000
ED      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128971.000000 Bid 128971.000000 Ask 132001.000000
EI      0       13:13:23.758    Core 1  2013.04.19 18:44:00   Last 128973.000000 Bid 128973.000000 Ask 132003.000000
 
dimnik:

You were right.

I did the ask price - it is higher by 3030 pips than bid/ask.

And on most of the history it is 10 pips (the real price step of this instrument), but on some of the history it goes up to 3030 pips (at 18:44 in the underscore).

How do we change that?

You can't. Such is the trading history, especially these are 2013 quotes.
Reason: