Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
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
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 819 guests, and 3 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
ExitLong/Short not behaving as expected #443772
07/24/14 10:28
07/24/14 10:28
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Hi all

I am having some trouble getting the exitLong and exitShort functions to behave as I'd like them to. In the code below, 'Red' refers to a series of prices that I designate as the 'red line'. I want to exit longs if price closes below it, and exit shorts if price closes above it. This code doesn't seem to be working. Can anyone help?

Many thanks

Code:
if (TradeIsLong and TradeResult > 0 and TradeTime > 1 and priceClose()< Red[0])
exitLong(0);
if (TradeIsShort and TradeResult > 0 and TradeTime >1 and priceClose() > Red[0])
exitShort(0);


Re: ExitLong/Short not behaving as expected [Re: boatman] #443778
07/24/14 12:35
07/24/14 12:35
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Hi boatman. What do you mean by "some trouble"? Have you tried adding debug printf's of Algo and the various other variables to see what's really going on?

HTH.

Re: ExitLong/Short not behaving as expected [Re: DdlV] #443781
07/24/14 14:10
07/24/14 14:10
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Hi Ddlv,

Thanks for that suggestion, I will give it a try. I guess I was being lazy and hoping someone could see an error in my code!

Its a strange one - it seems to work as I want it to in test mode, but when I trade it on a demo, these exits aren't honoured. Really strange behavior, but I'm sure I will get to the bottom of it.

Cheers

Re: ExitLong/Short not behaving as expected [Re: boatman] #443782
07/24/14 14:24
07/24/14 14:24
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I see apparent errors, but DdlV is right: debug the script. If it does not work, asking on the forum is silver, but finding it out yourself is gold. Debug a script even if it seems to work.

Your "TradeIsLong" and the other TMF variables make no sense here. You probably looked on the wrong page in the manual. Probably you wanted to use trade statistics variables such as "NumOpenLong".


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