Code problem with time conditions
Forums › ProRealTime English forum › ProOrder support › Code problem with time conditions
- This topic has 7 replies, 6 voices, and was last updated 5 years ago by Vonasi.
-
-
02/15/2018 at 11:39 AM #62809
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.
02/15/2018 at 2:27 PM #62834ProOrder 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
1BarIndex - TradeIndexwhich 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
1IF BARINDEX-TRADEINDEX(1)>5 AND Close-TRADEPRICE(1)>10 AND LongOnMarket THENsee line 15 at https://www.prorealcode.com/documentation/tradeprice/, where both condition are used to exit a Profitable trade after 5 bars have elapsed.
1 user thanked author for this post.
02/16/2018 at 11:15 AM #62899Thanks!
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?
02/16/2018 at 1:28 PM #62918So 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.
02/16/2018 at 7:06 PM #62940You 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
GraHal1 user thanked author for this post.
05/23/2018 at 4:48 PM #71195Hi Thought my problem was related to this and so I added it here.
I want to close a trade after 5 bars so wrote:
1234567891011if LongonMarket and (BarIndex-TradeIndex) < 4 thenTrade = 1elseTrade = 0//conditions to close tradesetc etc Trade =0However 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
05/23/2018 at 5:19 PM #7119905/24/2018 at 1:16 PM #71247 -
AuthorPosts
Find exclusive trading pro-tools on