Gamestudio Links
Zorro Links
Newest Posts
No connection to MT4
by JeyKey II. 10/29/26 09:34
Zorro plugin for Hyperliquid.xyz
by opm. 10/28/26 13:50
Icon "OP"
by JeyKey II. 10/27/26 07:03
ZorroGPT
by TipmyPip. 10/26/26 08:09
Chat Room for Zorro Programmers
by Haitao_Ren. 10/25/26 03:14
Trading Journey
by Haitao_Ren. 10/25/26 03:14
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (LucasJoshua, JeyKey II, mayarik), 13,059 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Haitao_Ren, JimSimons, julienp, julienper, KelleyAbbey
19247 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,837
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,837
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,837
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,837
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