Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (TipmyPip, AndrewAMD, dBc, clonman), 18,621 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ThisTrade crashes test #483325
05/19/21 14:36
05/19/21 14:36
Joined: Apr 2021
Posts: 41
Slovakia
T
tomna1993 Offline OP
Newbie
tomna1993  Offline OP
Newbie
T

Joined: Apr 2021
Posts: 41
Slovakia
Hi,

I would like to assign trade pointer to ThisTrade when I enter a trade in tick function, but it crashes the test. I tried it two ways:
Code
function tick()
{
	if (LongSignal && (priceClose(0) >= LongSignalEntry) && !TradeIsOpen)
	{	
		Lots = ceil(RISK / ((LongSignalEntry - GridTakeProfit[0]) * POINT_CURRENCY_VALUE));
		TRADE* RunningLongTrade = enterLong(LongTradeManagement);
	}	


and
Code
function tick()
{
	if (LongSignal && (priceClose(0) >= LongSignalEntry) && !TradeIsOpen)
	{	
		Lots = ceil(RISK / ((LongSignalEntry - GridTakeProfit[0]) * POINT_CURRENCY_VALUE));
		ThisTrade = enterLong(LongTradeManagement);
	}	


I think now that I can't assign to ThisTrade the trade pointer in tick function, I did not try it in run function, but anyway it's no way I open trade in run (because of low timeframes I trade).
I use trade variables in run and in TMF functions and they work correctly but I read in manual I should set ThisTrade to be sure that trade variables have correct values. There is !TradeIsOpen which is checked before trade is open. What can I do in that situations? Create a global bool variable and use it till I open trade?

Re: ThisTrade crashes test [Re: tomna1993] #483326
05/19/21 14:46
05/19/21 14:46
Joined: Feb 2017
Posts: 1,806
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,806
Chicago
TradeIsOpen is invalid until you specify a trade.

Perhaps you should be checking one of the trade statistics instead.
https://zorro-project.com/manual/en/winloss.htm

Re: ThisTrade crashes test [Re: tomna1993] #483330
05/20/21 13:08
05/20/21 13:08
Joined: Apr 2021
Posts: 41
Slovakia
T
tomna1993 Offline OP
Newbie
tomna1993  Offline OP
Newbie
T

Joined: Apr 2021
Posts: 41
Slovakia
Thanks for the idea Andrew, I'll try it!
After I opened a position can I use trade variables without assigning the enterLong function to ThisTrade?

Re: ThisTrade crashes test [Re: tomna1993] #483331
05/20/21 13:20
05/20/21 13:20
Joined: Feb 2017
Posts: 1,806
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,806
Chicago
No. ThisTrade must be assigned in order for trade variables to work.

Also, if a trade fails, enterLong can return 0 (a null pointer). So if ThisTrade is assigned a null pointer, accessing trade variables can crash your script. Always check that enterLong returns a valid pointer before using the pointer.

Re: ThisTrade crashes test [Re: AndrewAMD] #483333
05/20/21 17:11
05/20/21 17:11
Joined: Apr 2021
Posts: 41
Slovakia
T
tomna1993 Offline OP
Newbie
tomna1993  Offline OP
Newbie
T

Joined: Apr 2021
Posts: 41
Slovakia
Ohh, that was the problem! Thank you for your help! Have a nice day!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1