Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Quad, Ayumi, AndrewAMD), 1,092 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: Need help with script [Re: bfleming] #433348
11/28/13 12:40
11/28/13 12:40
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Ok, we're almost there!

Only one small issue remains. I'm putting that up as a puzzle to the users: Who can fix bfleming's script so that he is really placing an ATR stop? Hint: it's only one line that is wrong now. And what is the risk of his trading when it's not fixed?

Solution tomorrow. BTW, Zorro could theoretically fix this automatically or warn you with an error message - I'll put that on our to do list.

Re: Need help with script [Re: jcl] #433355
11/28/13 13:20
11/28/13 13:20
Joined: Oct 2012
Posts: 48
C
Chaosfreak Offline
Newbie
Chaosfreak  Offline
Newbie
C

Joined: Oct 2012
Posts: 48
Ok .. I'll try. wink

Line 4: LookBack = 0;

LookBack is set to 0, so all indicators don't have any lookback period and thus generate 0 as value. It's really dangerous because "Stop" will also be set to 0 and all trades will have no SL.

Re: Need help with script [Re: Chaosfreak] #433362
11/28/13 15:12
11/28/13 15:12
Joined: Jul 2013
Posts: 110
B
bfleming Offline OP
Member
bfleming  Offline OP
Member
B

Joined: Jul 2013
Posts: 110
Originally Posted By: Chaosfreak
Ok .. I'll try. wink

Line 4: LookBack = 0;

LookBack is set to 0, so all indicators don't have any lookback period and thus generate 0 as value. It's really dangerous because "Stop" will also be set to 0 and all trades will have no SL.


Alas, no... The original strategy has a lookback of 500. I ran the test script with a lookback period greater than 0 and the problem still persists. Also, the script without ATR stop had a lookback of 0 and worked fine.

(BTW, the "Error 014: Function ATR TimePeriod 60 > LookBack" that you see in FXCM_MT4 screenshot only appears when the platform has an ATR indicator running. Where there was no ATR indicator, there was no error message.)

Last edited by bfleming; 11/28/13 15:19.
Re: Need help with script [Re: bfleming] #433367
11/28/13 16:15
11/28/13 16:15
Joined: Oct 2012
Posts: 48
C
Chaosfreak Offline
Newbie
Chaosfreak  Offline
Newbie
C

Joined: Oct 2012
Posts: 48
You need at least a lookback of 60 for your example. ATR is a indicator which needs a lookback period.
If you don't use it, you need no lookback. That's why the script without ATR worked.

Attached Files lookback.jpg
Re: Need help with script [Re: Chaosfreak] #433371
11/28/13 16:43
11/28/13 16:43
Joined: Jul 2013
Posts: 110
B
bfleming Offline OP
Member
bfleming  Offline OP
Member
B

Joined: Jul 2013
Posts: 110
OK, I got it to work correctly when I tested the test script. But when I try to trade the test script with a lookback of 60 or higher I get:

Lots 10, Stop 0.0001, PIPCost 0.1000, Risk 3.05.
(EUR/USD::L) 16:41 Can't open 10@1.3601

So with a lookback >60 it doesn't open trades.

But more importantly, in the original strategy, as I said, I have a lookback period of 500, so how is that the issue then?

Re: Need help with script [Re: bfleming] #433425
11/29/13 13:40
11/29/13 13:40
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, it was the lookback = 0 line. The TradeTest script needed no lookback, but ATR is an indicator that needs past data. So your stop loss was never set, as you can see in your log.

Without a stop loss, Zorro assumes a risk of an 1% price move. The risk can not be zero, as some estimated value is needed for the performance calculation.

And your original script was fine as far as I see, only problem was that you seemed to have wrong expectations about the risk of a trade.

Re: Need help with script [Re: jcl] #433426
11/29/13 13:49
11/29/13 13:49
Joined: Jul 2013
Posts: 110
B
bfleming Offline OP
Member
bfleming  Offline OP
Member
B

Joined: Jul 2013
Posts: 110
OK, so after all this we've come full circle. My original script looks fine, and yet it's not calculating the risk properly. Any ideas??

BTW, as I mentioned above, when I tried to trade the test scrip with lookback >60 it couldn't open any trades.

Re: Need help with script [Re: bfleming] #433427
11/29/13 13:54
11/29/13 13:54
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Not many brokers would accept a trade with a 0.0001 stop loss. You need to set some reasonable value for entering a trade - check your broker's trade parameter limits. They are usually posted on his website.

And what is still the problem with the risk calculation? You can see the formula in the test script, so what have you not understood?

Re: Need help with script [Re: jcl] #433432
11/29/13 14:54
11/29/13 14:54
Joined: Jul 2013
Posts: 110
B
bfleming Offline OP
Member
bfleming  Offline OP
Member
B

Joined: Jul 2013
Posts: 110
JCL, I appreciate all the effort and help you given, and I've understood every step and understand everything you've pointed me to in the manual, but none of this has actually resolved the problem. The problem is still as it was in the first post. The original script - which you say looks fine - is opening trades with risk (and consequently also take profit) completely different from what the risk actually should be, namely: it opened with risk of 345 when it should be 34.5 in the case of the AUDUSD trade and risk of 391 when it should be 22 in the case of USDCHF trade.

We've established that:

1) my broker account is a micro account
2) I simulated the strategy on a micro account
3) the strategy has a sufficient lookback period for the ATR to function
4) Zorro is opening the test script correctly with the broker, with the correct risk based on ATR (I just confirmed that by increasing Stop = 10*ATR)

And yet, despite the fact that all of this is in order, when Zorro runs the original strategy, it gets the risk wrong.

So, is there anything else we should be looking at? Would it matter that I didn't train the strategy on the broker's data, but on the data downloaded from your site? Or if there was any price history missing? Or missing bars?

I've just amended the strategy to trade on the 1minute bar so I could watch it trade, and I can confirm that it's opened the trade with the proper risk. I'll return to running it on its proper time frame to see if the problem comes up again.

Last edited by bfleming; 11/29/13 15:15.
Re: Need help with script [Re: bfleming] #433435
11/29/13 15:43
11/29/13 15:43
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, we're now indeed back at the first post - and that's where I now must leave the circle. Sorry for not being able to help.

Better do not trade live at this point. You don't believe Zorro's risk calculation, but there are several books where the basics of trading are also explained in more detail - you can find some on the book list at the end of the manual.

If you have any other issues, just ask.

Page 2 of 3 1 2 3

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1