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

 
CJIeCaPb:

Ahh, pointed it out wrong, yes).

Re-checked separately. Only the sell ticket was wrong. Checked the rest too: orders, comparisons, modification. But I still have a stupor after placing orders. Everything worked fine on its own.

*Conditions for entering if(MA=MA1), is it wrong? Because =, is not a condition sign, the correct sign is "==", but if I spelled it that way the Expert Advisor does nothing at all. The other variants: ">=", "<=", "<", ">" that and "=" lead to placing orders and further stupor.

It is certainly not true, although the compiler will fix it, but who knows if it will correct it or not? Maybe it will substitute == or !=, or maybe it won't fix it at all but will simply ignore the check and set it always to true.

Compile the code with #property strict, there is a lot more to fix.

If we need to check for a crossover of 2 MAs, it is not checked by equality. The criterion must be something like "if MA1(2)<MA(2) and MA1(1)>MA(1) - then the second MA has crossed the first one upwards on the preceding candle". And equality can wait for a year.

And what is while(true), according to you?

Further:

 //+------------------------------------------------------------------06-----------------------------------------------

//Buy

while(OrderType()==1)//Buy (а вот нифига, бай = 0)

и чуть ниже
//--------------------------------------------------------------------------
//Sell
while(OrderType()==2) //опять же, селл = 1
 

How to organise an arrayof int type with 1 billion values and then sort it? Please, give me an example.

So far, with the standard means of MQL4 I can arrange an array of int numbers with only 2 million values.

 
solandr:

How to organise an array of int type with 1 billion values and then sort it? Please, give me an example.

So far, with the standard means of MQL4 I can arrange an array of int numbers with only 2 million values.

It's a good idea. Please calculate the necessary memory size
 
Vinin:
Good wish. Please calculate the amount of memory required
The problem is clear. But how to solve it? Are there any other ways other than directly creating an array? That is, how to sort out 1 billion values? Or is it impossible to think of a solution in MQL4?
 
evillive:

Of course, it is not correct, although the compiler will correct it, but who knows if it is correct or not? Or it may replace == with != or not fix it at all, but simply ignore the check and set it always to true.

Compile code with #property strict, there are a lot of things to fix.

If you need to check crossover of 2 MAs, it is not checked by equality, the criterion must be something like "if MA1(2)<MA(2) and MA1(1)>MA(1) - then the second MA has crossed the first one upwards on the preceding candle". And equality can wait for a year.

And what is while(true), according to you?

Further:


while(true) - a loop where I pick up the trend:

-if an order breaks through a stop (Time>0) I put it at the same place where it was;

- if it reaches a certain level(NormalizeDouble(OrderOpenPrice()+TP*Point,Digits)<=NormalizeDouble(Ask,Digits)), then it goes into another loop (where the condition is the order type) where the profit is calculated in points and is modified depending on that.

Concerning the condition ""If MA1(2)<MA(2) and MA1(1)>MA(1) - the second MA has crossed the first one upwards on the previous candle"". , do the numbers in brackets mean candles? Here is my variant MA>Open[0] || MA<Open[0], will it work?

#property strict prescribed, corrected errors.

I have changed the way to get profit in points: the obtained difference between the current price and the open price is divided by Point (line 217 and 271).

I made type conversions in lines: 218, 272, 369. Is it correct?

Two errors have appeared:

possible use of uninitialized variable 'Prof' Test3.mq4 222 15

possible use of uninitialized variable 'Prof' Test3.mq4 275 15

Files:
test3_6.mq4  15 kb
 

dear experts....recently started to learn mql4 basics....i have a question for you....let's say i have a main indicator and filters....if one condition on the main indi is fulfilled, then certain conditions from filters should coincide with it, but if another condition is fulfilled on the main indi, then filters should have other conditions......I need this to open a trade...Can I use || sign in this situation or still can't...any answer please explain in an understandable way as I am still a fool...Respectfully!

 
kempo102938:

dear experts....recently started to learn mql4 basics....i have a question for you....let's say i have a main indicator and filters....if one condition on the main indi is fulfilled, then certain conditions from filters should coincide with it, but if another condition is fulfilled on the main indi, then filters should have other conditions......I need this to open a trade...Can I use || sign in this situation or still can't...any answer please explain in an understandable way as I am still a fool...Respectfully!

Make up your mind. Do you want an "AND" or an "OR".
 
Taak.... the main indicator shows the bars of the chart in 5 different colours (green, blue, red, orange, grey). Sell trade: The main indi shows a grey bar-->the filters show their signals-->the trade is opened. If main indy shows orange bar-->filters show other signals.... etc. How do I correctly prescribe in the code so that trades don't repeat, because with every candle the colour of the main indi can jump "back and forth"...hope I explained the problem well...Respectfully!
 
CJIeCaPb:

while(true) - a loop where I pick up the trend:

And when do you think this loop should close?

if(R==0)
{
 while(true)
 {
  Sleep(30000);
  Alert("Ошибка!");
 }
}

?

CJIeCaPb:

About the condition ""If MA1(2)<MA(2) and MA1(1)>MA(1) - the second MA has crossed the first MA upwards on the previous candle"". , do the numbers in brackets mean candles? Here is my variant MA>Open[0] || MA<Open[0], will it do?

Yes, the candle number in brackets is the candle for which the MA value is taken. Yes, it will do with the opening price.

CJIeCaPb:

I have changed the method of getting profit in points: the obtained difference between the current price and the open price is divided by Point (line 217 and 271).

I made type conversions in lines: 218, 272, 369. Is it correct?

The Profit variable (to be declared as integer) is quite enough to calculate profit in pips, the other two are redundant:

 if(NormalizeDouble(Ask,Digits) <= NormalizeDouble(OrderOpenPrice(),Digits))
 {
  Profit = (int)((NormalizeDouble(OrderOpenPrice(),Digits)-NormalizeDouble(Ask,Digits))/Point);

  Profo = Profit/Point;
   Prof= (int)Profo;
 }
   
 if(OldProfit>Prof  Profit )
  continue;
 else
  OldProfit=Prof  Profit ; //ну и так далее, где профит считается

And there are a lot of stoploss trawls in kodobase, why should I invent a lissapet with rectangular wheels?

 
evillive:

And when do you think this cycle should close?

?

Corrected:

if(R==0)

{

 while(true)

 {

  Sleep(30000);

  Alert("Ошибка!");

  DeleteBuy=OrderDelete(OrderTicketBuy);

  DeleteSell=OrderDelete(OrderTicketSell);

  return(1);

 }

}

Calculation of profit too.

I inserted a message and error handling in the while (true) loop. The loop works, message is written, no errors. But it doesn't pass the condition, data doesn't seem to be updated.

Files:
test3_7.mq4  16 kb
Reason: