Inverted average of Gross P/L

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Inverted average of Gross P/L

Postby Cactus » Thu Oct 12, 2017 7:42 pm

Hello
I would like to request an indicator which is an average of the Gross P/L...
It means it would only appear if there are positions open

Some calculations explained here
http://www.fxcodebase.com/documents/Ind ... _math.html

When you open multiple positions, there is visible a "Net Short" or "Net Long" as a horizontal line on the chart. This is the price of breakeven for all positions in that direction.

I want the average to be drawn from this as the first value, and then consider how the price moves afterward against or in favour of your positions and adjust accordingly

I would like to request an average line of Gross P/L
But this line should be drawn on the chart just as price, not in its own window

To show average gross profit for individual symbol (which it is applied on) and separate long/short positions

So the thing is a gross p/l is just a simple value + if profit and - if loss, but I want it to appear on chart as a average...

It should also be inverted (drawn below net short horizontal line) if selling and price goes down.
Drawn above net long horizontal line if buying and price goes up

Hope it makes sense. I have provided a very silly screenshot.
Red circles are example short positions
Green line is net short profit
Blue line should be the average... of course in my example it is not drawn very correctly and looks like it is in real time, but the average should lag by x periods specified by user of course.

If it is no good I will provide further clarification with real chart.
Attachments
Untitled.png
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: Inverted average of Gross P/L

Postby Apprentice » Fri Oct 13, 2017 7:41 am

Your request is added to the development list under Id Number 3923
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Inverted average of Gross P/L

Postby Alexander.Gettinger » Wed Oct 18, 2017 8:15 pm

Please explain in more details how it should look.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Inverted average of Gross P/L

Postby Cactus » Fri Oct 20, 2017 8:43 pm

Ok. So:
"Net Short" appears once there is at least 2 short positions open
And "Net Long" if we have 2 long positions open

In below example, purple box is the Net Short (-45.5) <-- Negative because price is above it and we are selling. The horizontal line of Net Short value is 1.1405 (breakeven price)

I would like to see the average of this Net Short. To treat 1.1405 as a starting point
And adjust with price and if new positions are opened

ss1.png

Another example:
2 sell positions opened
ss1_1.png

4 more sell positions opened, so Net Short moved
ss1_2.png

How I would imagine the average to look like
ss1_3.png

I would like the average line to appear like so :
When selling: above Net Short if it is negative (loss) and below if it positive (gain)
When buying: below Net Short if it is negative (loss) and above if it positive (gain)

Now I am not exactly sure about the math necessary to make this work...
I was thinking something like:
Example with buy positions in negative territory:
position 1 = 1.14248
position 2 = 1.14258
price now = 1.14129
position 1 p/l = price now - position 1 (= -0.00119)
position 2 p/l = price now - position 2 (= -0.00129)
breakeven (net long) = (sum of positions) / number of positions (1.14253)
total P/L = (sum of positions p/l) ( = -0.00248)

Now imagine price moved up above breakeven:
[index 3] P/L is now 0.0035
average[3] = breakeven+(0.0035/number of positions) (= 1.14428)
[index 2] P/L is now 0.0015
average[2] = breakeven+(0.0015/number of positions) (= 1.14328)
[index 1] P/L is now 0
average[1] = breakeven+(0/number of positions) (= 1.14253)

Now the line drawn on the chart would be... 1.14336
average of (average[3], average[2], average[1])

I don't know if pip cost (0.8) or mmr (2.5) or spread would too take part in these calculations
Of course this should be separate for long / short so maybe 2 averages in same indicator?
If no positions open then average can disappear (0)
I hope this isn't very confusing

I think such indicator would make for a good stop loss dynamic line something like trailing ATR
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Google [Bot] and 9 guests