Questions from Beginners MQL4 MT4 MetaTrader 4 - page 88

 
Gregory Kovalenko:

Hello. How do I get the current profit/loss on the current open order?

Trying

- Returns only positive, profit, if position is in deficit at the moment, loss is not shown.

P.S. In order historyOrderProfit() shows minus as well.

How are you trying to get a profit, show all the code
 

regarding the current profit on the order (did not find the initiator of the post)

double profit=OrderProfit()+OrderSwap()+OrderCommission();
 
Renat Akhtyamov:

regarding the current profit on the order (did not find the initiator of the post)


Thank you, there was indeed an error in the logic of the code, that's why
double profit=OrderProfit()+OrderSwap()+OrderCommission();

did not work.

Now an interesting question has arisen.

I look at the last order in the history, I see a loss. I would like to decrease tp and increase lot. tp

MarketInfo(Symbol(),MODE_STOPLEVEL)

How do I calculate which lot is required, knowing the current price to open and the new tp - to close the loss?

 
Gregory Kovalenko:

Thanks, there was indeed an error in the logic of the code.

did not work.

Now this is an interesting question.

I look at the last order in the history and see a loss. I would like to decrease tp and increase lot. tp - how to calculate which lot is needed.

How do I calculate what lot is needed, knowing the current price to open and the new tp - to close the loss?

This question is interesting, but it is related to strategy development. Personally, I'll pass.
 
Gregory Kovalenko: How do you calculate which lot is required, knowing the current price to open and the new tp - to close the loss?

Calculates how much of the loss will be covered by an order with a lot equal to OrderLots(). Opens an order with a lot equal to OrderLots(), divided by the obtained value.

In other words, if the OrderLots() closes 0.5 losses, you open an order with the lot OrderLots()/0.5 = OrderLots()*2.

If OrderLots() closes the loss twice, use OrderLots() / 2

 
LRA:

Calculates how much of the loss will be covered by an order with a lot equal to OrderLots(). Opens an order with a lot equal to OrderLots(), divided by the obtained value.

It is easier to calculate how much of the loss will be covered by the order with lot = 1. Opens an order with lot = 1, divided by the resulting value.
 

I have a quadruple question.

everyone has a limit of 3000 pips in the chart settings, or does anyone have any vertical scaling working at all ?

here's a screenshotsjfhakslljas


 

Application of "looping programmes"

Please explain the pros and cons. Is it better than waiting for a new tick from start()? Does it increase response speed to a new tick?

start()
   {
   while(!IsStopped())
      {
      RefreshRates();
      //...
      Sleep(5);
      }
   return;
   }

 
smart_man:

Application of "looping programmes"

Please explain the pros and cons. Is it better than waiting for a new tick from start()? Does it increase response speed to a new tick?

start()
   {
   while(!IsStopped())
      {
      RefreshRates();
      //...
      Sleep(5);
      }
   return;
   }

You shouldn't do it. It will consume a lot of resources. And what's wrong with the response speed without looping?
 
smart_man Explain the pros and cons. Is it better than waiting for a new tick from start()? Does it increase the speed of response to a new tick?

   while(!IsStopped())
      {
      RefreshRates();
      //...
      Sleep(5);
      }

A tick is new data coming from the server. And it must be processed immediately after it arrives. If you do it in loop with delay of 5 ms, then most ticks will arrive namely during this delay. Thus, processing will be delayed by 0 ... 5 ms.
Reason: