Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (howardR, sleakz), 706 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Average entry price? #459951
06/12/16 23:44
06/12/16 23:44
Joined: Jun 2016
Posts: 33
NC
C
Cstyle Offline OP
Newbie
Cstyle  Offline OP
Newbie
C

Joined: Jun 2016
Posts: 33
NC
Within a zorro script, how do I tell what my entry price was? Likewise, if I've added to the position a couple times, how do I know the average entry price for my total position?

Thanks!

Re: Average entry price? [Re: Cstyle] #459960
06/13/16 07:42
06/13/16 07:42
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
The average entry price is the weighted sum of entry prices divided by number of trades. You can find all trade specific variables in the manual under "trade specific variables".

Re: Average entry price? [Re: jcl] #460030
06/13/16 22:40
06/13/16 22:40
Joined: Jun 2016
Posts: 33
NC
C
Cstyle Offline OP
Newbie
Cstyle  Offline OP
Newbie
C

Joined: Jun 2016
Posts: 33
NC
I see it now. Thanks a million!

Re: Average entry price? [Re: Cstyle] #460122
06/16/16 21:53
06/16/16 21:53
Joined: Jun 2016
Posts: 33
NC
C
Cstyle Offline OP
Newbie
Cstyle  Offline OP
Newbie
C

Joined: Jun 2016
Posts: 33
NC
Now that I'm digging into the trade specific variables, what I may need is the average profit of all open trades. Does TradeProfit give that? How does TradeProfit behave when more than one trade is open?

Here is an example:

You go long 1 lot at 100.
You add to your position, an additional lot, at 110.

What would be the value of TradeProfit when the asset is trading at 120?
Would it be 30 (total profit)?
15 (average profit)?
10 (the profit of the most recently opened trade)?
Other?

Thanks!

Re: Average entry price? [Re: Cstyle] #460131
06/17/16 07:49
06/17/16 07:49
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Neither. Here's how to calculate the average profit per trade:

Code:
var AverageProfit = 0;
int Count = 0;
for(open_trades)
  if(TradeIsOpen) {
    AverageProfit += TradeProfit;
    Count++;
  }
if(Count) 
  AverageProfit /= Count;



Untested, so try it at your own risk..


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1