The formula I use is here.

Account_Balance*Risk*0.01/Stop__Loss/Pip_Value.

This is pretty close to yours, however we're calculating Pip_Values differently.

The way I think about it is, you have to get the value of the Tick. This is usually the value of a Point. But what you want is the value of a Pip. You cannot simply say Pip_Value = Tick_Value*10; Because this'll be good for 5_digits brokers but fail on 4_digits brokers. If you can determine a 5_digit broker vs a 4_digit broker then simply multiply the Tick_Value by 10 or 1 in-order to get the Pip_Value. If you look around the forum, you'll find different ways of doing it. Some people divide and others multiply. Use a method which is easier for you to remember.

Once you've got the correct lotsize from the above equation, then you'll need to drop-off any floating decimals to ensure it goes into the broker lot_steps perfectly. Example: MathFloor( myRiskLots / Symbol_Lot_Step) * Symbol_Lot_Step;

You get Tick_Values via the MarketInfo(); Example double Tick_Value=MarketInfo(Symbol(),MODE_TICKVALUE);

{Added} MarketInfo for Symbols outside the testing Symbol does not work in mt4 strategy tester.

Hi,

I would like to make an indicator which has two extern variables: risk (in %) and stop loss. The indicator should print the correct lotsize in the upper right corner of the chart. But there is one issue I can't solve. For example, my loss is larger when I lose 20 Pips with a EURGBP-trade than with a EURUSD-trade. Therefore the lotsize depends on the stoploss size and the currency-pair I want to trade. This indicator should work by receiving the currency-information from the chart. So when I determine the risk and stoploss size in pips, the indicator must show different lotsizes according to the currency.

And this is my problem. How can I receive the chart's secondary currency? I only know that I get the currency pair by using Symbol(). But how can I only get the secondary currency? Or is the only possibility to check for ALL symbols for example ending with "JPY"? Something like IF(CurrencyPair=="AUDJPY" || CurrencyPair=="CADJPY" || CurrencyPair=="EURJPY" || .....) ?

Or can I just say IF(CurrencyPair ending with "JPY") .... ? But I have no idea for the syntax, if this is generally possible.

This is what I have so far (I make it for a Euro based account, therefore I calculate everything to Euro):