Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1257

 
Vladimir Karputov:

What does the number first mean? On each timeframe the current candle has an index of '0'.

For 5, counting from zero, you need the number of the first candle of that week, for example on Monday at 12 on the hour chart, the first candle will have the index rates_total-11, of course you can cycle through it and see the difference in candle dates for over 2 days, but I think there is a more elegant solution.

 

Good evening.
Do you know if you can use MQL5 to find out if the Expert Advisor is in tester mode or in real trading mode? If so, how?

Thank you.

 
DKarpoff:

For 5, starting from zero we need the number of the first candle in this week. For example on Monday at 12 on the hour chart the first candle will have rates_total-11 index , of course we can loop through it and see the difference in candle dates for more than 2 days, but I think there is a more elegant solution.

The current candlestick (on any timeframe) has the index '0', respectively the previous candlestick has the index '1'.

When working in the indicator, the current candlestick has the index 'rates_total-1' (if you don't flip arrays).

 
Vladimir Karputov:

The current candlestick (on any timeframe) through CopyXXX operation has index '0', respectively the previous candlestick has index '1'.

When working in the indicator, the current candle has the index 'rates_total-1' (if not to flip arrays).

The question is not about that, we need the index of the first candle of the current week.

In mql4, the DayOfWeek() function allows me to simply calculate the index I need.

 
DKarpoff:

The question is not about that, I need the index of the first candle of the current week.

In mql4 there was a function DayOfWeek() where you could simply calculate the index I need.

The index of trade opening candle of last Monday, the nearest Monday, depending on TF, of course. For the indicator.
 
Vladimir Karputov:

You can see the commission in the TRADE ( Class CDealInfo.Commision) or in the POSITION ( Class CPositionInfo.Commission )

Thank you. What about identifier POSITION_COMMISSION ?

It is not highlighted in the editor, and it is not in Help.

 
Can you tell me why in mt5, where the positions and orders are explicitly separated -ORDER_TYPE_SELL?
 
Andrey Sokolov:

Thank you. What about POSITION_COMMISSION identifier ?

It's not highlighted in the editor and it's not in the help.

I have it figured out. It is in the trades in the history

 
DKarpoff:

The question is not about that, I need the index of the first candle of the current week.

In mql4, there was the DayOfWeek() function that could simply calculate the index I need.

An index is an index. The current candle on any timeframe is index '0'.


Maybe you need to rephrase your question as follows: "I work in the INDICATOR on timeframe H1 and I need to know the index of the first candle on a given day of the week. Have I phrased your question correctly?

 
Vladimir Karputov:

An index is an index. The current candle on any timeframe is index '0'.


Maybe you need to rephrase your question as follows: "I work in the INDICATOR on the H1 timeframe and I need to know the index of the first candle on a given day of the week". Did I phrase your question correctly?

I need to loop through the candlesticks in the indicator, but not from the 0th but from the first candlestick of the previous week.

for(int i=0; i<rates_total; i++) - this is all bars

and we need something like:

X=(IndexFirstTradingWeek(EURUSD,H1))+120;

for(int i=(rates_total-X); i<rates_total; i++)

Reason: