MQL4 code to generate order according to a previuos loss

 
Good evening,

I'm a beginner MQL4 developper. I have a question:

1) Suppose I open a trade position with a Take Profit of 5pips and no SL with 0.01 Lot

2)SUppose I close the position with a loss of 0.40 $

3)If I want recover the previuos loss opening a new position with a TP always of 5 pips how many lot I have to play?

Could someone give me the formula?

Thanks a lot
 
Claudio Lasso:

1) Suppose I open a trade position with a Take Profit of 5pips and no SL with 0.01 Lot

2)SUppose I close the position with a loss of 0.40 $

3)If I want recover the previuos loss opening a new position with a TP always of 5 pips how many lot I have to play?
  1. Do you really mean 5 PIPs?
              What is a TICK? - MQL4 programming forum

  2. No SL means you aren't managing risk.
    Never risk more than a small percentage of your account, certainly less than 2% per trade, 6% total.
    1. In code (MT4): Risk depends on your initial stop loss, lot size, and the value of the pair.
      1. You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
      2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
      3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                  MODE_TICKVALUE is not reliable on non-fx instruments with many brokers.
      4. You must normalize lots properly and check against min and max.
      5. You must also check FreeMargin to avoid stop out
      Most pairs are worth about $10 per PIP SL is $5/$10/5=0.1 Lots maximum.

  3. You want $0.40 = lots * (5 pips plus the spread) * $10/pip.
 
William Roeder:
  1. Do you really mean 5 PIPs?
              What is a TICK? - MQL4 programming forum

  2. No SL means you aren't managing risk.
  3. You want $0.40 = lots * (5 pips plus the spread) * $10/pip.

thanks a lot!!

Reason: