Does anyone have working NinjaScript code to do the following (supported or unsupported methods welcome):
- Identify base currency of the account
- Identify available account balance
- Calculate the available margin at any time in real-time
- Calculate the value per pip in real-time for any combination of circumstances:
- Trading any currency pair (e.g. EURCHF)
- Account in any base currency (e.g. GBP)
- Going long or short
- Any account configuration: one pip, half pip or tenth pip
- Calculate stop loss parameters for any order where any of the following may be fixed or variable:
- Risk amount in base currency of the account or any other currency
- Stop loss size in pips
- Going long or short
- Number of units to buy or sell short (i.e. fractional lotsize, not rounded)
- Calculate PnL accurately in real-time for any position
- Calculate take profit parameters for any position where any of the following may be fixed or variable:
- Profit amount in base currency of the account or any other currency
- Take profit size in pips
- Long or short position
- Number of units to sell or buy to cover (i.e. fractional lotsize, not rounded)
Whilst I am aware of a number of NinjaScript data structures and methods that can determine some of these things, there are quite a few things I do not know, including some uncertainty on the formulae to use. I am looking for comprehensive code to implement all these things. I'm happy to consolidate code snippets, so long as the overall effect is to produce the above in a robust, accurate (preferably elegant) method. I will repost any end-result code.
Many thanks!

Comment