Questions from Beginners MQL5 MT5 MetaTrader 5 - page 913

 
Mikhail Rudyk:

Hello

Please advise how to correctly replace the expression

trend[i] = (i<Bars-1) ? (price>amax[i+1]) ? 1 : (price<amin[i+1]) ? -1 : trend[i+1] : 0;

with operators (if and else)

thank you

Like this

// trend[i] = (i<Bars-1) ? ( (price>amax[i+1]) ? 1 : (price<amin[i+1]) ? -1 : trend[i+1] ) : 0;
if(i<Bars-1) {
 if(price>amax[i+1]) 
  trend[i] = 1;
  else {
  if(price<amin[i+1])
   trend[i] = -1;
  else
   trend[i] = price<amin[i+1];
  }
} else {
  trend[i] = 0;
}
 
Mikhail Rudyk:

Hello

Please tell me how to correctly replace the expression

trend[i] = (i<Bars-1) ? (price>amax[i+1]) ? 1 : (price<amin[i+1]) ? -1 : trend[i+1] : 0;

with operators (if and else)

thanks

You don't. Because this expression is written in error.

How does the operator read ?

assign value1 to the variable when the condition is met, otherwise value2

The compound operator looks like this:

int x;
x = a == 3 ? 1 : a == 2 ? 7 : 9;
int x;
if(a == 3)
 x = 1;
else if(a == 2)
 x = 7;
else 
 x = 9;

If a==3, assign value 1 to variable x otherwise if a == 2, assign value 7 to variable x in all other cases, assign value 9 to variable x;

 

Good evening. A question for distinguished connoisseurs. Has anyone seen, or can you suggest where to look?

I am looking for an open source Expert Advisor, or a class, or a code fragment with a clear algorithm.

The purpose - to virtually simulate the account operation on real quotes. That is, an Expert Advisor or indicator installed on a real account takes real quotes and simulates the trading inside itself.

The results of this trade are displayed in any available way for further analysis.

I would be very grateful for any links or ideas on this or near this subject

 
Sergey Voytsekhovsky:

Good evening. A question for distinguished connoisseurs. Has anyone seen, or can you suggest where to look?

I am looking for an open source Expert Advisor, or a class, or a code fragment with a clear algorithm.

The purpose - to virtually simulate the account operation on real quotes. That is, an Expert Advisor or indicator installed on a real account takes real quotes and simulates the trading inside itself.

The results of this trade is displayed in any available way for further analysis.

I will be very grateful for any links or ideas on this or circum-ethical topics

And you for what market?

 
Vladimir Karputov:

Can be based on OnChartEvent and CHARTEVENT_CHART_CHANGE event identifier - any graph change. You can check it in a timer (e.g. once per second).

Here is an example based on OnChartEvent and CHARTEVENT_CHART_CHANGE event identifier:

It's funny, if you hold the cursor on the price scale and move the mouse up, the numbers will twitch, i.e. as if the screen area is resized for a moment, but then it stabilizes back.

Is there any way to auto-expand the screen to a given number of points?
 

making an EA with iAO and iAC...

the logic is simple colour matching!!! both green, then BUY, both red SELL
but something is not working!!! lots of bugs, green-red!!! look at plz...

if(CopyBuffer(handle_AO_0, 0, 0, 200, AO_0) <= 0)
   return;     

if(CopyBuffer(handle_AC_0, 0, 0, 200, AC_0) <= 0)
   return;

ArraySetAsSeries(AO_0, true);
ArraySetAsSeries(AC_0, true);

//--- (BUY) possibility
  if(AO_0[1] > AO_0[2] && AC_0[1] > AC_0[2])
        {
         if(m_trade.Buy(lot, _Symbol, m_symbol.Ask(), 0, 0, magic))
           {
            Print("BUY order opened : ",m_trade.ResultPrice());
           }
        }

  //--- (SELL) possibility
  if(AO_0[1] < AO_0[2] && AC_0[1] < AC_0[2])
        {
         if(m_trade.Sell(lot, _Symbol, m_symbol.Bid(), 0, 0, magic))
           {
            Print("SELL order opened : ",m_trade.ResultPrice());
           }
        }
 
ponochka:

I am making an Expert Advisor with iAO and iAC...

the logic is simple colour matching!!! both green, then BUY, both red SELL
but something is not working!!! lots of bugs, green-red!!! look at plz...

1. In MQL5 there is basically no concept of green, red indicator.

2. Specify account type: netting or hedge

3. Give full code. Specify the symbol and timeframe. Specify time frame.

4. Show trades and chart with trades.

 

Good afternoon, forum users!!!

I'm asking for help again!

My question is this: I set a variable as an external parameter

input ENUM_TIMEFRAMES per_candle=PERIOD_D1;                          //период расчета худших и лучших результатов

After the first trade which has happened in the time period from the beginning to the end of the implementation.

first_buy

the time passed in the code should not be shorter than the time specified in theper_candle parameter.

This way it doesn't work

if (TimeCurrent()>first_buy+per_candle)

For some reason, at the period of one dayfirst_buy+per_candle, only 4 hours are added.

The trade was at 00:00.

Please help who knows what I am doing wrong.

 
ISL:

Good afternoon, forum users!!!

I'm asking for help again!

My question is this: I set a variable as an external parameter

After the first trade which has happened in the time period from the beginning to the end of the implementation.

the time passed in the code should not be shorter than the time specified in theper_candle parameter.

This way it doesn't work

For some reason, at the period of one dayfirst_buy+per_candle, only 4 hours are added.

The trade was at 00:00.

Please help who knows what I am doing wrong.

This is one (script in the trailer).

PERIOD_CURRENT 1
PERIOD_M2 2
PERIOD_M3 3
PERIOD_M4 4
PERIOD_M5 5
PERIOD_M6 6
PERIOD_M10 10
PERIOD_M12 12
PERIOD_M15 15
PERIOD_M20 20
PERIOD_M30 30
PERIOD_H1 16385
PERIOD_H2 16386
PERIOD_H3 16387
PERIOD_H4 16388
PERIOD_H6 16390
PERIOD_H8 16392
PERIOD_H12 16396
PERIOD_D1 16408
PERIOD_W1 32769
PERIOD_MN1 49153

This is two:PeriodSeconds

Files:
 
Vladimir Karputov:

This is one (the script is in the trailer)

This is two:PeriodSeconds

Thank you very much!!!

Reason: