Multi position ask and bid

Created at 07 Jan 2014, 11:24
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
lec0456's avatar

lec0456

Joined 14.11.2012

Multi position ask and bid
07 Jan 2014, 11:24


I use the following code to calculate the highest number of pips a single position or set of positions goes against a trade. So, if it goes 20 pips against you and then comes back, at the close of the trade I know how far it drew down the account for strategy analysis purposes.

foreach(Position position in Positions)
                {
                    if (position.TradeType == TradeType.Buy)
                    MaxDrawDown = Math.Max(Math.Round((position.EntryPrice - Symbol.Bid) / Symbol.PipSize, Symbol.Digits), MaxDrawDown);
                    else
                    MaxDrawDown = Math.Max(Math.Round((Symbol.Ask - position.EntryPrice) / Symbol.PipSize, Symbol.Digits), MaxDrawDown);
                } 

it will only work with single currency.  because it subtracts from the Symbol.Bid(or Ask)  How can I get this o work with multiple currencies there is no bid or ask in the position object.  I assume I could use position.symbolcode to get the currency pair but then how do I use that to return the pairs ask and bid?

 


@lec0456
Replies

lec0456
07 Jan 2014, 11:36

Ah, forget it.  

you just use:

 MarketData.GetSymbol(position.SymbolCode).Bid

Found it in a post...


@lec0456