Questions from Beginners MQL5 MT5 MetaTrader 5 - page 769

 
Vitaly Muzichenko:

Thanks for the reply, but how to make it work, I have no idea

I'll try one last time to reach out... I don't have an account with such tools indicated in the problem, but here's a script working on forex. The result coincides with the values that appear as hints in this screenshot

Forum on trading, automated trading systems & strategy testing

FAQ from Beginners MQL5 MT5 MetaTrader 5

Vitaly Muzichenko, 2017.07.26 23:56

I have one lot buy open, and when I set takeprofit, terminal recalculates it into dollars, because my account is dollar-denominated,

But when I calculate it using the formula (close_price-open_price)*Lots*TickPrice/TickSize, then my takeprofit amount is calculated in rubles.

On the chartSBRF-9.17

If we divide ruble by dollar rate 174.99/USDRUR = $2.93, we will get takeprofit in dollars.

How to write it programmatically and make it calculate itself?

/********************Script program start function*******************/
void OnStart()
{
 for(int i = 0; i < PositionsTotal(); i++)
  {
   ulong positionTicket = PositionGetTicket(i);
   string positionSymbol = PositionGetString(POSITION_SYMBOL);
   ENUM_POSITION_TYPE positionType = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
   double positionTP = PositionGetDouble(POSITION_TP);
   double positionOpen = PositionGetDouble(POSITION_PRICE_OPEN);
   double point = SymbolInfoDouble(positionSymbol, SYMBOL_POINT);
   int profitPoint = int(fabs(positionOpen-positionTP)/point);
   double positionProfit = PositionGetDouble(POSITION_PROFIT);
   string symbolCurrencyProfit = SymbolInfoString(positionSymbol, SYMBOL_CURRENCY_PROFIT);
   int currentProfit = positionType == POSITION_TYPE_SELL
    ? int((positionOpen-PositionGetDouble(POSITION_PRICE_CURRENT))/point)
    : int((PositionGetDouble(POSITION_PRICE_CURRENT)-positionOpen)/point);
   Print("PositionSymbol ", positionSymbol);
   Print("SymbolCurrencyProfit ", symbolCurrencyProfit);
   Print("PositionTP ", DoubleToString(positionTP, (int)SymbolInfoInteger(positionSymbol, SYMBOL_DIGITS)));
   Print("PositionOpen ", DoubleToString(positionOpen, (int)SymbolInfoInteger(positionSymbol, SYMBOL_DIGITS)));
   Print("PositionProfit ", DoubleToString(positionProfit, 2));
   Print("ProfitPoint ", profitPoint);
   Print("CurrentProfit ", currentProfit);
   Print("ИТОГО ", positionProfit/currentProfit*profitPoint);
  }
   
}/*******************************************************************/

I have 2 positions open. Here is the result of the script

2017.07.27 13:30:48.517 posi (EURUSD,M15)       PositionSymbol EURGBP
2017.07.27 13:30:48.517 posi (EURUSD,M15)       SymbolCurrencyProfit GBP
2017.07.27 13:30:48.517 posi (EURUSD,M15)       PositionTP 0.88697
2017.07.27 13:30:48.517 posi (EURUSD,M15)       PositionOpen 0.89197
2017.07.27 13:30:48.517 posi (EURUSD,M15)       PositionProfit 14.47
2017.07.27 13:30:48.517 posi (EURUSD,M15)       ProfitPoint 500
2017.07.27 13:30:48.517 posi (EURUSD,M15)       CurrentProfit 109
2017.07.27 13:30:48.517 posi (EURUSD,M15)       ИТОГО 66.37614678899082
2017.07.27 13:30:48.517 posi (EURUSD,M15)       PositionSymbol EURJPY
2017.07.27 13:30:48.517 posi (EURUSD,M15)       SymbolCurrencyProfit JPY
2017.07.27 13:30:48.517 posi (EURUSD,M15)       PositionTP 130.940
2017.07.27 13:30:48.517 posi (EURUSD,M15)       PositionOpen 130.440
2017.07.27 13:30:48.517 posi (EURUSD,M15)       PositionProfit -0.90
2017.07.27 13:30:48.517 posi (EURUSD,M15)       ProfitPoint 500
2017.07.27 13:30:48.517 posi (EURUSD,M15)       CurrentProfit -9
2017.07.27 13:30:48.517 posi (EURUSD,M15)       ИТОГО 50.0


BUT!!! Unfortunately, by the time the position is closed, no one will ever guess what will be the quote of profit currency to deposit currency. In this regard, an absolutely accurate value is impossible to determine. Well, there is no way to look into the future.

 
Vitaly Muzichenko:

No, to calculate profit/loss before opening a position, but in the currency of the deposit, not the instrument

Why do you need to know profit/loss in your case, not to control risks? - I was just curious - the currency of the deposit is clear, although it is not clear in what real-world conditions it would be used.
 
Alexey Viktorov:

I'll try to reach out one last time... I don't have an account with the tools mentioned in the problem, but here's a script that works in forex. The result coincides with the values that appear as a hint as in this screenshot


I have 2 positions open. Here is the result of the script work


BUT!!! Unfortunately, by the time the position is closed, no one will ever guess what will be the quote of profit currency to deposit currency. In this regard, an absolutely accurate value is impossible to determine. Well there is no way to look into the future.

Here is what the script showed:

2017.07.27 18:22:33.684 Seascape (SBRF-9.17,M15)        PositionSymbol SBRF-9.17
2017.07.27 18:22:33.684 Seascape (SBRF-9.17,M15)        SymbolCurrencyProfit RUR
2017.07.27 18:22:33.684 Seascape (SBRF-9.17,M15)        PositionTP 16777
2017.07.27 18:22:33.684 Seascape (SBRF-9.17,M15)        PositionOpen 16677
2017.07.27 18:22:33.684 Seascape (SBRF-9.17,M15)        PositionProfit 1.07
2017.07.27 18:22:33.684 Seascape (SBRF-9.17,M15)        ProfitPoint 100
2017.07.27 18:22:33.684 Seascape (SBRF-9.17,M15)        CurrentProfit 64
2017.07.27 18:22:33.684 Seascape (SBRF-9.17,M15)        ИТОГО 1.671875
 
Vitaly Muzichenko:

This is what the script showed:

Vitaly, you can figure it out yourself... The principle is simpler than 3 rubles...

PositionGetDouble(POSITION_PROFIT);

Returns the profit of the position in the currency of the deposit. If we divide this value by the number of points between the opening and the current price, we get the point value in the deposit currency... It only remains to multiply the value by the number of pips from opening to tp and that's it... But since I'm not able to, and too lazy to register a new account for this, you have to figure it out yourself. But just do not know what you should get, how can you know if the result is correct or not? You may have to print some additional values to understand. What counts as a clause? I don't know, maybe it has to be taken into account somehow. Or is the size of the standard contract somehow taken into account... I don't know.

 

How to understand the grey graph


in normal picture mode


 

In MT4 you point the mouse on the chart and you can see what point it is - but here the picture is static - ugly.

 
How do I plot the optimisation by a specific indicator (profit/loss/fv)?
 
Hello everyone. I have a problem, I've uploaded money to my MQL5 account and downloaded the MetaTrader 5 application, but I can't transfer the money to it to start trading. I need help.
 
Minora125:
Good afternoon to all . I've got a problem, I've uploaded money to my MQL5 account and I've also downloaded the MetaTrader 5 application, but I can't transfer the money to it to start trading. I need help.

MQL5 is not a brokerage company, it does not allow you to trade on a real account. For transferred money you can use services: Freelance, Market, Cloud.

Send your request to Service Desk (there is a link in your profile) and ask for a refund as wrongly transferred money.

 

After a pass in the tester, a chart opens with trades, how do I turn this off?

Reason: