Hi I got 2 questions about my code.
1. I want to take entry between 17:20-17:30 if my signal i active, but it seems that the entry is in the next bar? It should be in the signal bar.
2. I also want to do my exit between 17:20-17:30, is it possible to do a “noExitBeforeTime” and “noExitAfterTime”? The idea is to sell between 17:20-17:30 if the position is in profit. After 5 bars I will sell anyway.
[attachment file=62810]
ProOrder ALWAYS runs strategies when the signal bar closes and opens a trade, if conditions are met, afterwards, that’s why there’s one bar difference, though it may be just microseconds! This is true as of the caurrent version, the new one in the works is said to behave differently.
As for your 2nd question, to exit after n bars you may use the expression
BarIndex - TradeIndex
which returns the number of bars elapsed since the trade was started. If you want to add a condition to exit only if in profit you have to just check the current (closing) price and TradePrice as
IF BARINDEX-TRADEINDEX(1)>5 AND Close-TRADEPRICE(1)>10 AND LongOnMarket THEN
see line 15 at https://www.prorealcode.com/documentation/tradeprice/, where both condition are used to exit a Profitable trade after 5 bars have elapsed.
Thanks!
So I will allways miss the GAP to the next bar? This will happen often since I will trade daily timeframe. I got the version 10.3.
And the same will be in point number 2, if I want to sell on the bar when stockmarket close at 17:30, the sell will be next morning?
So I will allways miss the GAP to the next bar? This will happen often since I will trade daily timeframe. I got the version 10.3. And the same will be in point number 2, if I want to sell on the bar when stockmarket close at 17:30, the sell will be next morning?
Yes that’s how it behaves.
You could exit manually at 17:30 via the IG App on your phone then start your Daily TF Algo again later before you go to bed and before midnight?
Ha … I just thought of another way … if you leave your PC / Laptop running it appears that you could set an Alert and an associated Trigger to sell / buy and then this will close your Algo. All external interference with an Algo will close it down!
I’ve not tried about with date/ time so test it out and let us know how you get on?
See attached
GraHal
Hi Thought my problem was related to this and so I added it here.
I want to close a trade after 5 bars so wrote:
if LongonMarket and (BarIndex-TradeIndex) < 4 then
Trade = 1
else
Trade = 0
//conditions to close trades
etc etc Trade =0
However this closes every subsequent trade on the first bar. I’ve tried a once Trade = 1 after the close the trade instruction doesn’t work either.
Any help with this would be appreciated
Found a solution
c5 = (TradeIndex +5 = BarIndex)
This will close if c5 is in the sell conditions for a long trade
I’m glad that you found your solution Dymjohn.
Can I ask you to please use the ‘Insert PRT Code’ button in future posts as it makes everything much more readable for others. I’ve tidied up your posts here for you.