Estimating the net profit of a potential position

Created at 04 Nov 2024, 16:04
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!
CT

ctid5996231

Joined 26.06.2024

Estimating the net profit of a potential position
04 Nov 2024, 16:04


Hi all,

I have an extension method to calculate a rough estimate of the net profit should I launch a position and it reaches the target price, see below….
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
	public static class Extensions {


		public static double EstimateNetProfitAtPrice(this Symbol symbol, TradeType tradeType, double targetPrice, double volume) {

			double pips = 0;

			if(tradeType == TradeType.Buy) {
				pips = (targetPrice - symbol.Ask) / symbol.PipSize;
			} else {
				pips = (symbol.Bid - targetPrice) / symbol.PipSize;
			}

			return (pips * symbol.PipValue * volume) - symbol.Spread;

		}

    }
}

I think this is close but I've not included any commissions / swaps as I can't quite figure out how to include these in the calculation… How can I do this?

Also, any tips on how I can make it more accurate would be useful.

Many thanks in advance!

Mat


@ctid5996231
Replies

firemyst
05 Nov 2024, 05:46 ( Updated at: 05 Nov 2024, 08:03 )

For Commissions, you can look at these previous threads for guidance:

https://ctrader.com/forum/ctrader-algo/9495/

https://ctrader.com/forum/cbot-support/2395/

 

https://ctrader.com/forum/connect-api-support/37922/

 


@firemyst

ctid5996231
05 Nov 2024, 12:15

Extremely useful links, thank you!

Mat


@ctid5996231