How to read the lot size from the buy/sell buttons UI

To add comments, please log in or register
danielsokolowsk
50
danielsokolowsk  
Is it possible to read lot size from the buy/sell UI in top left corner of a chart? If so could someone paste some code? Is it possible to do so doing some `user.dll` call?
Jose Francisco Casado Fernandez
5160
Jose Francisco Casado Fernandez  
Do you mean One Click Trading Panel ??
whroeder1
17943
whroeder1  
  1. I don't think it's possible.
  2. Why do you care? It means nothing until the human clicks the button and a order opens.
danielsokolowsk
50
danielsokolowsk  

I care, because I could automatically adjust my visual max risk indicator line

Fernando Carreiro
4401
Fernando Carreiro  
danielsokolowsk: I care, because I could automatically adjust my visual max risk indicator line

Then use (or create) a trading assistant panel, for example as described in the following article: Creating an assistant in manual trading.

There are also a few other such types of assistants available in the CodeBase, for example the Money Manager Graphic Tool, which was latter improved by @whroeder1 (see his discussion post).

whroeder1
17943
whroeder1  
danielsokolowsk: I care, because I could automatically adjust my visual max risk indicator line
  1. In code: Risk depends on your initial stop loss, lot size, and the value of the pair.
    • 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.
    • Account Balance * 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.)
    • 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 (EUR, in this case).
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers.
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out
    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5=0.1 Lots maximum.
  2. Use a EA GUI such as the one for MT4: Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 5
  3. Your doing it backwards, Human adjusts the SL line and your code should compute and display the maximum lot size.
To add comments, please log in or register