Gamestudio Links
Zorro Links
Newest Posts
folder management functions
by 7th_zorro. 04/16/24 13:19
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (7th_zorro), 442 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 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,724
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

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

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