Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,507 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 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