Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
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 (AndrewAMD, rki), 390 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: TradeProfit while TradeIsClosed [Re: Sphin] #455091
10/09/15 00:47
10/09/15 00:47
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Hi Sphin. I have played with TradeProfit and yes, TradeProfit is updated with each tick; and yes, (var)TradeProfit works for printing.

Re. the former, however, if you're after the final TradeProfit, you'll have to wait until TradeIsClosed, and per jcl's comments in a for(all_trades) loop at the Bar, not in the TMF.

Regards.

Re: TradeProfit while TradeIsClosed [Re: DdlV] #455104
10/09/15 19:04
10/09/15 19:04
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Thanks DdlV!

But again I have this issue of different results with and without a TMF that should not change anything but only writing TradeProfit to the log. I tried it with Zorro 1.36.4 on 2 different PCs (one real, one VPS) with 2 different OS's (Windows 10 Home and Windows Server 12) and get the same results. I hope anyone, best jcl, can retrace this fact because its very confusing for me.

The code:

Code:
int TradeLong() {
   
   if (TradeIsNewBar) // not printing every tick only once per bar
      print(TO_LOG,"\nTradeProfit: %.2f",(var)TradeProfit);
   
}

function run()
{
   set(PLOTNOW+LOGFILE+TICKS);
	vars Price = series(price());
	vars Trend = series(LowPass(Price,500));
	
	Stop = 4*ATR(100);
	TakeProfit = 10*PIP;

	if(valley(Trend) && NumOpenLong == 0) 
		enterLong();
}




In this version without using the TMF I get always following result:

Annual +23% +93p

If you look at the 1st trade:

[EUR/USD::L5601] Long 1@1.3771 Risk 9$ p at 06:00
[757: Wed 17.02.10 07:00] +0 -2 0/1
[758: Wed 17.02.10 08:00] +0 +0 1/0
[EUR/USD::L5601] Target 1@1.3781: +0.82 at 08:05

It is not exciting, the trade behaves like expected, Zorro exits reaching the TakeProfit at 1.3781 after 10 PIPs.


Now I change:

-- enterLong();
++ enterLong(TradeLong);


a) In most cases, I get the following results:

Annual Loss: -29p

Let's now Look at its 1st trade (the other trades behave analogously):

[EUR/USD::L5601] Long 1@1.3771 Risk 9$ p at 06:00
TradeProfit: 0.05
[EUR/USD::L5601] Exit 1@1.3772: +0.05 at 06:00

I don't know why Zorro exits at 1.3772 while TakeProfit = 10*PIP and in this case this event would be logged as "Target" not as "Exit".


b) Sometimes (but very seldom), if I change:

-- enterLong();
++ enterLong(TradeLong);

in SED, click 'Save' and 'Test' without restart of Zorro:

Annual +23% +93p (same as without TMF), but then take a look at the logged trades:

e.g. 1st trade:

[EUR/USD::L5601] Long 870351@1.3771 Risk 8000543$ p at 06:00
[757: Wed 17.02.10 07:00] +0 -1356395 0/1
[758: Wed 17.02.10 08:00] +0 +326559 1/0
[EUR/USD::L5601] Target 870351@1.3781: +713160$ at 08:05

Funny! laugh The other trades behave the same way and TradeProfit is not written to Log.

Re: TradeProfit while TradeIsClosed [Re: Sphin] #455131
10/10/15 21:25
10/10/15 21:25
Joined: Mar 2015
Posts: 336
Rogaland
N
nanotir Offline
Senior Member
nanotir  Offline
Senior Member
N

Joined: Mar 2015
Posts: 336
Rogaland
I also understood TradeProfit as the current profit of the trade. I am using it to change the trailing while it is open in a TMF function. Not sure now, if I am using it right tongue

Re: TradeProfit while TradeIsClosed [Re: nanotir] #455141
10/11/15 01:36
10/11/15 01:36
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
It seems that TradeProfit indeed does it and if it was logged it was also logged with the right value although during a TMF obviously something happens that should not happen and leads to completely strange results.

Page 2 of 2 1 2

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