Page 1 of 2

Problem to exit position - because not at he end of turn

PostPosted: Tue Sep 17, 2019 8:46 am
by william17
Hello,

I need help please,

Im using a strategy who works with MACD to exit position.
You can see it in attached file.

My problem is that the algorithm not calculate the position output at the end of the period: if there is a wick during candle ans the position exit signal is here, it doesn't recalculate at the end of turn
And if at the end of turn, there is no signal to exit position, it close the order still !!

For information, in this strategy, i want the MACD close order when the slope is different from the order opening

Someone could help me please,

Thank you

Re: Problem to exit position - because not at he end of turn

PostPosted: Wed Sep 18, 2019 6:52 am
by Apprentice
Your request is added to the development list.
Development reference 107.

Re: Problem to exit position - because not at he end of turn

PostPosted: Thu Sep 19, 2019 12:58 pm
by Apprentice
Aroon_up.lua
(30.88 KiB) Downloaded 319 times

Try this version.

Re: Problem to exit position - because not at he end of turn

PostPosted: Thu Oct 10, 2019 7:44 am
by william17
Hello Apprentice,

Thank you for your reply, but unfortunately, it dosen't going well…
Indeed, it calculate only during candle, and not at the end of turn…

It is possible to use the following function :

function CreateTradingParameters

strategy.parameters:addString("ExecutionType", "End of Turn / Live", "", "End of Turn")
strategy.parameters:addStringAlternative("ExecutionType", "End of Turn", "", "End of Turn")
strategy.parameters:addStringAlternative("ExecutionType", "Live", "", "Live"

With this trading parameters, we should have the signal only at the end of the candle, isn't it?

Re: Problem to exit position - because not at he end of turn

PostPosted: Thu Oct 10, 2019 12:33 pm
by Apprentice
Your request is added to the development list.
Development reference 176.

Re: Problem to exit position - because not at he end of turn

PostPosted: Mon Oct 14, 2019 5:33 am
by Apprentice
Aroon_up.lua
(130.14 KiB) Downloaded 323 times

Try this version.

Re: Problem to exit position - because not at he end of turn

PostPosted: Fri Oct 18, 2019 3:45 am
by william17
Hello Apprentice,

Thank you for your reply,

But there is a problem…
For open position, apparently and for the moment no problem, but for close position, it's getting a candle to late!!
So when we have the exit signal, the position close one candle later!
And more, the signal generated must be < or > and not ≤ or ≥

Have you an idea?

Re: Problem to exit position - because not at he end of turn

PostPosted: Mon Oct 21, 2019 5:25 am
by Apprentice
To get faster exit you need to use "Live" mode

Re: Problem to exit position - because not at he end of turn

PostPosted: Tue Oct 29, 2019 1:36 pm
by william17
Thank you!
It works well…

And i like your version, because there are différent options and it looks complete

I have some changes to make, if it's possible,

I would like to work on the following idea,

indicators : Ichimoku, RSI, ADX, SAR, MACD,

For buy:
Open buy when SAR UP change to SAR DOWN and,
If the price close current is > SA (-26) and SB (-26)
If the RSI n-1 is lower of level 50 (with adjustable value)

Close buy if MACD n-1 is > MACD current, or if RSI is ≧ 70 (with adjustable value)


Idem for sell:
Open sell when SAR DOWN change to SAR UP and,
If the price close current is < SA (-26) and SB (-26)
If the RSI n-1 is upper of level 50 (with adjustable value)

Close sell if MACD n-1 is < MACD current, or if RSI is ≤ 30 (with adjustable value)


Small precision, if i want to use this strategy on 2 timeframes, (H1 and 15mn)
if i have a signal to close a position in 15 mn, can it close only the position on 15 mn and not on H1 (if a position is open too on H1)?

Thank you for your help

Re: Problem to exit position - because not at he end of turn

PostPosted: Wed Oct 30, 2019 5:48 am
by Apprentice
Your request is added to the development list.
Development reference 262.