ExitLong/Short not behaving as expected

Posted By: boatman

ExitLong/Short not behaving as expected - 07/24/14 10:28

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);

Posted By: DdlV

Re: ExitLong/Short not behaving as expected - 07/24/14 12:35

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.
Posted By: boatman

Re: ExitLong/Short not behaving as expected - 07/24/14 14:10

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
Posted By: jcl

Re: ExitLong/Short not behaving as expected - 07/24/14 14:24

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".
© 2024 lite-C Forums