Questions from Beginners MQL5 MT5 MetaTrader 5 - page 907

 
Vladimir Karputov:

If a question is asked, I will answer it. I'm not a telepath.

My question is this:))

How do I enter a trade not with specified lots, but with a percentage of the existing deposit?

 
ISL:

question like this))

How do I enter a trade not with specified lots, but with a percentage of my existing deposit?

Example:OHLC Check code. If you set the Risk parameter other than zero - this will be the percentage of risk (do not forget to set the Lot parameter to zero).


Added: replaced the link - the first link was wrong. Sorry.

 
Vladimir Karputov:

Example:OHLC Check code. If you set Risk other than zero - this will be risk percentage (don't forget to set Lot parameter to zero).


Added: changed link - first link was wrong. Sorry.

Wrong question, how to close percentage of position of the whole position in this symbol?

 
ISL:

Slightly wrong question, how do I close the position percentage of the entire position in a given symbol?

PositionClosePartial

Closes part of the position on the specified symbol or with the specified tick

 
Vladimir Karputov:

PositionClosePartial

Closes part of a position at the specified symbol or with the specified ticket

Thank you!

 

Good evening!

The adviser is making transactions. Only it is necessary that I already have a position, to divide all funds equally into 5 characters.

In part.

void OnTick()

I cannot do that because this splitting will be repeated at every tick.

How can I be in position immediately?

Thank you in advance.

 

Hi all!

Please share, who knows and knows how to prohibit the EA from selling after a stop triggering?

 
Guys, please advise how to make automatic selection request.type_filling = // ORDER_FILLING_FOK ORDER_FILLING_IOC ORDER_FILLING_RETURN I can not think and constantly change is not good
 
TYRBO:
Guys, please advise how to automatically select request.type_filling = // ORDER_FILLING_FOK ORDER_FILLING_IOC ORDER_FILLING_RETURN I can not think and constantly change is not good

You can search the code here:

https://www.mql5.com/ru/code/16006

MT4Orders
MT4Orders
  • www.mql5.com
Данная библиотека позволяет работать с ордерами в MQL5 (MT5-hedge) точно так же, как в MQL4. Т.е. ордерная языковая система (ОЯС) становится идентичной MQL4. При этом сохраняется возможность параллельно использовать MQL5-ордерную систему. В частности, стандартная MQL5-библиотека будет продолжать полноценно работать. Выбор между ордерными...
 
TYRBO:
guys, could you please advise how to automatically select request.type_filling = // ORDER_FILLING_FOK ORDER_FILLING_IOC ORDER_FILLING_RETURN I can not figure out how to change it myself.

Connect the standard trading classCTrade
(it comes standard with the terminal)

//+------------------------------------------------------------------+
//|                                                          XXX.mq5 |
//+------------------------------------------------------------------+
#property version   "1.000"
//---
#include <Trade\Trade.mqh>  
CTrade         m_trade;                      // trading object
input ulong    m_magic        = 228364430;   // magic number
//---
ulong          m_slippage=10;                // slippage
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   m_trade.SetExpertMagicNumber(m_magic);
   m_trade.SetMarginMode();
   m_trade.SetTypeFillingBySymbol(Symbol());
   m_trade.SetDeviationInPoints(m_slippage);

and call two methods:

SetTypeFillingBySymbol

Sets the order type according to the specified symbol

SetMarginMode

Sets the margin calculation mode according to the current account settings

Reason: