Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, alibaba, Quad), 761 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Closed Order Missing πŸ˜‚ #480932
07/26/20 00:56
07/26/20 00:56
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
Dear all, I am working on a strategy. Before it start a new position, it will check the latest closed order in the same direction. If the latest closed order in the same direction loose money, no new position will be started. But I found one of the closed order can not be found by:
Code
function lastTradeFail(string direction, int timeDif, bool mute){
	string asset_tmp = Asset;
	for(closed_trades){
		if(strcmp(asset_tmp,"CHF/JPY")==0 && strcmp(Asset,"CHF/JPY")==0 && !mute){	
			printf("\n***********: %s, %.4f, %d, %d",Asset, (var)TradePriceClose, ymd(TradeExitDate), ymd(wdate()));
		}
	}
}

Output of "20200717" (last order start date):
Code
Test: _portfolio4  2020
Assets AssetsFXCMLite_19
Read _portfolio4.fac
Warning 048: trade loop recursion
***********: CHF/JPY, 113.4548, 20200716, 20200717
***********: CHF/JPY, 114.0899, 20200714, 20200717


By comparing the The TradePriceClose and TradeExitDate, I found this order [CHF/JPY::S28133] is missing. This order was recorded in the log file:
Quote

[3281: Thu 20-07-16 14:00] 1994 +22.97 26/19 (113.44)
Warning 048: trade loop recursion
[CHF/JPY::S28133] Short 7@113.45 Risk 24 t at 14:00:00

[3302: Fri 20-07-17 11:00] 1957 +37.26 27/23 (113.84)
[CHF/JPY::S28133] Stop 7@113.91: -24.32


[Linked Image]

After hours of debuging, I don't have a clue any more. Please help ~~~

Attached Files
closed_order_missing.JPG (75 downloads)
Last edited by AdamWu; 07/26/20 01:02.
Re: Closed Order Missing πŸ˜‚ [Re: AdamWu] #480933
07/26/20 01:07
07/26/20 01:07
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Rewrite your script so that it is not causing trade loop recursion. TLR causes all kinds of nasty side effects.

Re: Closed Order Missing πŸ˜‚ [Re: AdamWu] #480934
07/26/20 01:40
07/26/20 01:40
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
Originally Posted by AndrewAMD
Rewrite your script so that it is not causing trade loop recursion. TLR causes all kinds of nasty side effects.

Hi AndrewAMD, thank you for your quick replyπŸ‘. I found out if the checking function (lastTradeFail) return true, and the main process start a new position, then the TLR warning will show up.

Am I wrong in the process?

Code
                if(crossOver(Signal,Threshold)){
			if(Price[0]>MySignal[0] || lastTradeFail("long",3600*24*2,true)==1){
				if(lastTradeFail("short",3600*24*2,false))
					return;
				enterShort();
			}
		}

Attached Files
loop_recurision.png (64 downloads)
Last edited by AdamWu; 07/26/20 01:42.
Re: Closed Order Missing πŸ˜‚ [Re: AdamWu] #480945
07/26/20 12:18
07/26/20 12:18
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
I’d need to see the rest of the script to answer that.

Generally, you get that warning if you either:
* Nest a macro loop inside a macro loop or
* Break from the macro loop without using the macro break.

I’m guessing it’s the latter.

Re: Closed Order Missing πŸ˜‚ [Re: AndrewAMD] #480946
07/26/20 15:11
07/26/20 15:11
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
Originally Posted by AndrewAMD
I’d need to see the rest of the script to answer that.

Generally, you get that warning if you either:
* Nest a macro loop inside a macro loop or
* Break from the macro loop without using the macro break.

I’m guessing it’s the latter.

You are absolutly right. I didn't close the macro loop properly. Thank you so much!πŸ‘πŸ‘πŸ‘

For any newbie like me who have the same problem, the macro loop can be closed like this:
Code
function lastTradeFail(){
	bool res = false;
	for(closed_trades){
		...
		res = true;
		break_trades;
	}
	return res;
}

Last edited by AdamWu; 07/27/20 10:42.
Re: Closed Order Missing πŸ˜‚ [Re: AdamWu] #480949
07/26/20 19:28
07/26/20 19:28
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
Originally Posted by AdamWu
[quote=AndrewAMD]

For any newbie like me who have the same problem, the macro loop can be closed like this:


Can you post the complete sample please?

Re: Closed Order Missing πŸ˜‚ [Re: danatrader] #480955
07/27/20 10:46
07/27/20 10:46
Joined: May 2020
Posts: 45
A
AdamWu Offline OP
Newbie
AdamWu  Offline OP
Newbie
A

Joined: May 2020
Posts: 45
Hi danatrader, I updated above post to make it more specific. If you want to discuss more about the strategy, Please Please Please join our discussion: https://discord.gg/yfxyrNu


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