3 registered members (AndrewAMD , alibaba , Quad ),
761
guests, and 2
spiders.
Key:
Admin ,
Global Mod ,
Mod
Closed Order Missing π
#480932
07/26/20 00:56
07/26/20 00:56
Joined: May 2020
Posts: 45
AdamWu
OP
Newbie
OP
Newbie
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:
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):
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:
[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
After hours of debuging, I don't have a clue any more. Please help ~~~
Attached Files
Last edited by AdamWu; 07/26/20 01:02 .
Re: Closed Order Missing π
[Re: AdamWu ]
#480934
07/26/20 01:40
07/26/20 01:40
Joined: May 2020
Posts: 45
AdamWu
OP
Newbie
OP
Newbie
Joined: May 2020
Posts: 45
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?
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
Last edited by AdamWu; 07/26/20 01:42 .
Re: Closed Order Missing π
[Re: AndrewAMD ]
#480946
07/26/20 15:11
07/26/20 15:11
Joined: May 2020
Posts: 45
AdamWu
OP
Newbie
OP
Newbie
Joined: May 2020
Posts: 45
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:
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
danatrader
Senior Member
Senior Member
Joined: Mar 2019
Posts: 357
[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?