Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1431

 

I want to download free Expert Advisors to MQL5. I go to Expert Advisors, then to Free Expert Advisors. Question: can I use all the Expert Advisors in the "free" section on my real account or are there any restrictions? If an Expert Advisor says

"already bought" it can be put on a real account or not?

 
mikhail2929 Кравченко real account or are there any restrictions? If an Expert Advisor says on it

"already bought" it can be put on a real account or not?

Good day! If you downloaded a free Expert Advisor and there is information that it has already been purchased, you can use it. The question is different - how reliable is it? For this purpose, before using it on a real account, it is better to test the Expert Advisor!

Regards, Vladimir.

 
MrBrooklin #:

Good day! If a free Expert Advisor has been downloaded and there is information that it has already been purchased, you can use it. The question is different - how reliable is it? For this purpose, before using it on a real account, it is best to test the Expert Advisor!

Regards, Vladimir.

Thank you Vladimir. I understand that testing and optimisation are necessary. I.e. all Expert Advisors placed in the "free" section can be downloaded and installed to work on a real account without restrictions. Do I understand correctly?

 
Good afternoon, I am looking for help, when writing an MT5 Expert Advisor, I use CTrade class to modify TP and SL. The problem is that the position is initially set TP and SL after TP is changed but SL should remain in place, when implementing it turned out like this :
 for(int i = 0; i <= PositionsTotal(); i++)
      if(a_position.SelectByIndex(i))
         if(a_position.Magic() == MagicNumber && a_position.Symbol() == a_symbol.Name())
            if(PositionGetString(POSITION_COMMENT) == Comment_2)
              {
                  if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && PositionGetDouble(POSITION_TP) != TP_Buy)
                  a_trade.PositionModify(PositionGetInteger(POSITION_TICKET),PositionGetDouble(POSITION_SL),TP_Buy);

                  if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && PositionGetDouble(POSITION_TP) != TP_Sell)
                  a_trade.PositionModify(PositionGetInteger(POSITION_TICKET),PositionGetDouble(POSITION_SL),TP_Sell);
              }

TP_Buy and TP_Sell are counted correctly. In the tester it gives error 4756. CTrade::OrderSend: modify position #4 GBPUSD (sl: 1.35950, tp: 1.34860) [invalid stops] failed modify #4 sell 0.05 GBPUSD sl: 1.35950, tp: 1.34860 -> sl: 1.35950, tp: 1.34860 [Invalid stops]. As I understand it is an error of SL setting, most likely the error is due to the fact that SL is in the same place. But this is what I need. In the CTrade manual it is written that "if the change is not needed, the previous value". How to overcome the error, please tell me.

 
mikhail2929 Кравченко #:

Thank you Vladimir. I understand that testing and optimisation is necessary. I.e. all Expert Advisors placed in the "free" section can be downloaded and installed for work on a real account without restrictions. Do I understand correctly?

I think I already answered your question earlier. Yes, you have understood correctly.

Regards, Vladimir.

 
rexMetaL writing an MT5 Expert Advisor, I use CTrade class to modify TP and SL. The problem is that the position is initially set TP and SL after TP is modified but SL should remain in place, when implementing it turned out that :

TP_Buy and TP_Sell are counted correctly. In the tester it gives error 4756. CTrade::OrderSend: modify position #4 GBPUSD (sl: 1.35950, tp: 1.34860) [invalid stops] failed modify #4 sell 0.05 GBPUSD sl: 1.35950, tp: 1.34860 -> sl: 1.35950, tp: 1.34860 [Invalid stops]. As I understand it is an error of SL setting, most likely the error is due to the fact that SL is in the same place. But this is what I need. In the CTrade manual it is written that "if the change is not needed, the previous value". How to overcome the error, please tell me.

Hello!

First of all, remove the equal sign in the loop so that it will be like this:

for(int i = 0; i < PositionsTotal(); i++)

I did not look at your code further.

Regards, Vladimir.

 
MrBrooklin #:

Hello!

First of all, remove the equal sign in the loop:

I haven't looked at your code further.

Regards, Vladimir.

Nothing has changed, the problem is specifically in SL/TP
 for(int i = 0; i < PositionsTotal(); i++)
      if(a_position.SelectByIndex(i))
         if(a_position.Magic() == MagicNumber && a_position.Symbol() == a_symbol.Name())
            if(PositionGetString(POSITION_COMMENT) == Comment_2)
              {
                  if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && PositionGetDouble(POSITION_TP) != TP_Buy)
                  a_trade.PositionModify(PositionGetInteger(POSITION_TICKET),PositionGetDouble(POSITION_SL),TP_Buy);

                  if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && PositionGetDouble(POSITION_TP) != TP_Sell)
                  a_trade.PositionModify(PositionGetInteger(POSITION_TICKET),PositionGetDouble(POSITION_SL),TP_Sell);
              }
 
MrBrooklin #:

Hello!

First of all, remove the equal sign in the loop, so that it would be like this:

I didn't look at your code further.

Regards, Vladimir.

Thank you for your time, the problem was solved by simple rounding of SL/TP by instrument. The error was because SL/TP were taken from the indicator.

Thank you.

 
mikhail2929 Kravchenko #:

Thank you Vladimir. I understand that testing and optimisation is necessary. I.e. all Expert Advisors placed in the "free" section can be downloaded and installed to work on a real account without restrictions. Do I understand correctly?

It is better not to do it :)

 

Hello everyone,

I'm new so I hope I'm writing in the right place: I'm trying to code an EA that could help me with my money management, like :

"close all trades when past losses+current drawdown are below x%" + "close all trades immediately until end of session/day".

If anyone knows how to do this or can help me it would be great to get in touch.

Thanks, trade well ;)

Reason: