Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (1 invisible), 672 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 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,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
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