No new trades at time / existing trades don't close
Forums › ProRealTime English forum › ProOrder support › No new trades at time / existing trades don't close
- This topic has 11 replies, 5 voices, and was last updated 6 years ago by GraHal.
-
-
02/15/2018 at 9:53 AM #6279702/15/2018 at 10:59 AM #62801
No position is closed until you tell the system to.
You may use SELL/EXITSHORT or DEFPARAM FLATAFTER.
02/15/2018 at 11:32 AM #62805Hello,
I don’t use DEFPARAM flatafter but I use DEFPARAM flatbefore. So the system closes at 000000. That’s what I told the system so I understand that.
But how can I tell otherwise that the first trade should not be opened before 10 o clock and run till the stop or target is reached (maybe that can take even some days)
02/15/2018 at 12:43 PM #62824You shouldn’t use either DEFPARAM FLATBEFORE nor DEFPARAM FLATAFTER. You should, instead, use variables to set your desidered time interval.
123456789ONCE NoEntryBefore = 100000ONCE NoEntryAfter = 180000..IF time >= NoEntryBefore AND time <= NoEntryAfter THENBUY/SELLSHORT....ENDIF..1 user thanked author for this post.
03/02/2018 at 8:16 AM #64208This is what I’m trying to use but I have a problem or I moreover I believe PRT has a problem.
My platform is set the Australian Eastern Standard Time and I don’t want any trades to open on Saturday after 05000. It sort of works with the TIME function but it also stops trades on Friday. I’ve tried to set endOfWeek = 6 but that doesn’t work. Am I missing something simple? Or is this really a PRT time/day issue?
123456789101112131415161718192021222324// No trades on Monday until 12 MiddaystartOfweek = 0startHour = 120000// If use this code it stops trades from opening on Saturday but for some reason also Friday until midnight?endOfWeek = 5 //endHour = 050000IF (CurrentDayOfWeek = startOfweek AND time < startHour ) OR (CurrentDayOFWeek = endOfWeek AND time > endHour) THENtradingHours = 0ELSEtradingHours = 1ENDIFIF NOT ONMARKET AND tradingHours = 1 THENBUY 1 CONTRACT AT MARKETENDIFIF ONMARKET THENSELL 1 CONTRACT AT MARKETENDIFSET TARGET pPROFIT 10SET STOP pLOSS 1003/02/2018 at 10:29 AM #6421303/02/2018 at 11:25 AM #64217Monday is 1, while 0 is Sunday.
I tested it on Aud/Nzd, h1 and the output (with GRAPH) is:
- at 22:00 UTC+0 both DayOfWeek and OpenDayOfWeek (or CurrentDayOfWeek) return the same value (0=sunday, 1=monday,…)
- at 23:00 UTC+0 OpenDayOfWeek returns the current day (0 on Sunday,…) while DayOfWeek returns the next day (1 on Sunday, 2 on monday,…)
it appears that the discriminating factor is 23:00 UTC+0 (00:00 CET).
1 user thanked author for this post.
03/02/2018 at 12:11 PM #64221Robert thanks for checking with your set timezone. I thought this would be the case so this to me reconfirms this is a IG PRT issue with Days timezone.
Please remember for me the Monday is working fine with it set to “0” even though I know technically this is Sunday but it works, that’s what’s important (note setting DayOfWeek = 1 : doesn’t work) but my major issue is the Friday and Saturday problem.
As you can see on Friday after it stops making trades and then on Saturday at 00:00 it starts making again but then stops at 050000 as it’s supposed to by why does it stop trading on Friday? It shouldn’t.
Grahal yes you’re sought of right (I suggest you re-read my problem description ), the code SELL ON MARKET is somewhat superfluous because there’s the pProfit/pLoss but I’ve included to make sure it closes the position every hour so that we can see when it is or isn’t working to execute BUY as per the time instructions. The problem is that it doesn’t execute BUY trades on Friday after 11:00 AEST but it should.
1 user thanked author for this post.
03/02/2018 at 1:02 PM #64225As for ONMARKET, it takes one candle to be true, so your code will allow one bar before any trade is closed.
To close immediately after a BUY within the same candle the code should be:
1234IF NOT ONMARKET AND tradingHours = 1 THENBUY 1 CONTRACT AT MARKETSELL 1 CONTRACT AT MARKET //or just SELL AT MARKET, since no partial closing is allowed so farENDIFeven if I can’t figure out what use it would be, unless for some debugging purposes.
1 user thanked author for this post.
03/02/2018 at 10:36 PM #6424403/03/2018 at 11:13 AM #64267To check values for days, simply run this strategy and take note of what GRAPH reports (the last 3 lines are useless, they do nothing but ate least one Buy is required by PRT):
123456GRAPH CurrentDayOfWeekGRAPH OpenDayOfWeekGRAPH DayOfWeekif close < 0 thenbuy at marketendif03/03/2018 at 4:55 PM #64300 -
AuthorPosts
Find exclusive trading pro-tools on