Questions from a "dummy" - page 146

 
alph:

Hello!

Here, I've sculpted it, adjusted it for GBPUSD M30.

Would like an opinion, comment and advice as well.

Thanks in advance.

Maybe:

Slipage=20; // Slippage

Include in:

if(_Digits==4 || _Digits==2)
{
STP = STP/10;
TKP = TKP/10;

}

It's too big for 4 digits.

I tried it on 2 brokerage companies and did not manage to get a positive result.

May be the server time is different from mine.

What brokerage company are you using?

 
pusheax:


You're right, I hadn't even thought about it.

RFC DC

Server time MSC-3

 
alph:

Hello!

Here, I have sculpted it, adjusted it for GBPUSD M30.

I would like an opinion, comment and advice as well.

Thanks in advance.

I ran a glance at it. Here's a look.

1.

bool timeOntrade(int TradeHour)
   {
   MqlDateTime timeOntrade;
   TimeTradeServer(timeOntrade);
   if(timeOntrade.hour!=TradeHour) return(false);
   timeOntrade.hour= 0;
   timeOntrade.min = 0;
   timeOntrade.sec = 1;
   if(timeOntrade.hour==4 || timeOntrade.hour==15 || timeOntrade.hour==16) return(true);
   return(true);
   }

The last and penultimate lines are confusing. Whatever the result of the if() operator is, it returns true. What is the sense of this condition then? It is the same in timeOntrade2().

2. When using the OrderSend() function, the programmer checks neither its success, nor the return code result.retcode. So far it looks as follows: if a trade request is sent, the matter is the same :) No one cares if it worked or not.

 

 alph:

3. If OnInit() fails to get at least one indicator handle, why not just unload the programme?

 
Yedelkin:

I ran a glance around. Here's a look.

1.

The last and penultimate lines are confusing. Whatever the result of the if() operator is, it returns true. What is the sense of this condition then? It is the same in timeOntrade2().

2. When using the OrderSend() function, the programmer checks neither its success nor the return code result.retcode. So far it looks as follows: if a trade request is sent, the matter is the same :) No one cares if it worked or not.

That's why I'm asking for an opinion and advice. I don't fully understand the processes in mql, but deals are opened this way and at the right time. When I tried it with one timeframe, it didn't work.
 
Yedelkin:

3. If OnInit() fails to get at least one indicator handle, why not just unload the programme?

The way is reliable, but not always effective. In my opinion, it is correct to correct all errors and defects of initialization, if possible.
 
Yedelkin:

3. If OnInit() fails to get at least one indicator handle, why not just unload the programme?

Can you tell me how?
 
alph:
That's why I'm asking for an opinion and advice. I don't fully understand the mql processes, but in this way trades open at the right time, and when I tried with one timeframe I failed.

Yes it is "opinion and advice"! :) I'm not saying the code is a bummer; I'm saying there are doubts. Please feel free to write what you want to code - they will help you here.

About the OrderSend() function: Look at its description. The result variable contains the server's response. It must be analyzed. Everyone analyzes it in his/her own way. Please ask, if something is not clear.

Документация по MQL5: Торговые функции / OrderSend
Документация по MQL5: Торговые функции / OrderSend
  • www.mql5.com
Торговые функции / OrderSend - Документация по MQL5
 

alph:

Yedelkin : 3. If OnInit() fails to get at least one indicator handle, why not just unload the program?

Please, tell me how to do it.

Look at description of OnInit(). It says that if the int OnInit() function returns a non-zero return code, it means unsuccessful initialization, at which theDeinit event with REASON_INITFAILED code of the deinitialization reason is generated. Simply speaking, if OnInit() fails to receive an indicator handle, write return(-100) and the expert will finish its work. (Value "-100" is conditional; any non-zero value is sufficient).

 
Yedelkin:

Yes it is "opinion and advice"! :) I'm not saying the code is a bummer; I'm saying there are doubts. Please feel free to write what you want to code - they will help you here.

About the OrderSend() function: Look at its description. The result variable contains the server's response. It must be analyzed. Everyone analyzes it in his/her own way. Please, ask if something is not clear.

If the price closes below the moving average, and Momentum is below the average - we open the deal to sell. To buy on the contrary.

"I have no idea what to do with this kind of code. Thanks for the tips.

Reason: