‘cannot convert ?Double to Double’
‘cannot convert ?Double to Double’
11 Feb 2018, 12:21
Hi All...
I’m trying to use the Take Profit level of an open position to calculate the target price of a new Pending Order…
As cAlgo only accepts a take profit level in pips I need to convert the Take Profit value back to PipSize to make a price level calculation, but the error ‘cannot convert ?Double to Double’ is returned….
foreach (Position position in symbolSearch) { if (position.TradeType == TradeType.Sell) { // TP is converted back to pipSize for a price calculation, we need to set the price level as our low with the entry price being the high, this range will be the basis for our fib calculation var TPinPipSize = position.TakeProfit * Symbol.PipSize; // Then we subtract the TP value away from the open short position entry price to create a TP price level var TPprice = position.EntryPrice - TPinPipSize; // Then we use the fib levels calculation of low - gap * 0.161 to create an inverted fib level extension of High (short position entry price) and low (short posotion TP price) var TargetPrice = TPprice - (position.EntryPrice - TPprice) * 0.161;
Can anyone spot my error?!?! usually I would use print statements to spot any glaring errors but I can't even get it to build...
Many thanks,
Drummond
Replies
Drummond360
11 Feb 2018, 23:55
Ah that simplifies the whole thing! Thank you very much Markae...
@Drummond360
markae
11 Feb 2018, 13:44
This is a nullable double.
Try to use this value for your calculations:
@markae