Hello,
is it possible that there are no new trades opened by the system at 22 o clock but the positions which are still open will not be closed?
Thanks a lot
No position is closed until you tell the system to.
You may use SELL/EXITSHORT or DEFPARAM FLATAFTER.
Hello,
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)
You shouldn’t use either DEFPARAM FLATBEFORE nor DEFPARAM FLATAFTER. You should, instead, use variables to set your desidered time interval.
ONCE NoEntryBefore = 100000
ONCE NoEntryAfter = 180000
.
.
IF time >= NoEntryBefore AND time <= NoEntryAfter THEN
BUY/SELLSHORT....
ENDIF
.
.
This 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?
// No trades on Monday until 12 Midday
startOfweek = 0
startHour = 120000
// If use this code it stops trades from opening on Saturday but for some reason also Friday until midnight?
endOfWeek = 5 //
endHour = 050000
IF (CurrentDayOfWeek = startOfweek AND time < startHour ) OR (CurrentDayOFWeek = endOfWeek AND time > endHour) THEN
tradingHours = 0
ELSE
tradingHours = 1
ENDIF
IF NOT ONMARKET AND tradingHours = 1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF ONMARKET THEN
SELL 1 CONTRACT AT MARKET
ENDIF
SET TARGET pPROFIT 10
SET STOP pLOSS 10
Isn’t below your problem? Where is your Sell condition?? Aren’t you exit / Sell at the next bar after Entry or maybe even Buy then Sell one after the other in the same Bar?
IF ONMARKET THEN
SELL 1 CONTRACT AT MARKET
ENDIF
Monday 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).
Robert 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.
As 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:
IF NOT ONMARKET AND tradingHours = 1 THEN
BUY 1 CONTRACT AT MARKET
SELL 1 CONTRACT AT MARKET //or just SELL AT MARKET, since no partial closing is allowed so far
ENDIF
even if I can’t figure out what use it would be, unless for some debugging purposes.
hi guys
I’m a rookie, but I think there isn’t a ZERO day.
Monday is 1
sunday is 7
that’s what I knew.
Am I wrong ?
To 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):
GRAPH CurrentDayOfWeek
GRAPH OpenDayOfWeek
GRAPH DayOfWeek
if close < 0 then
buy at market
endif
Thanks Roberto ( as always! ) seems Sunday is 0 and Friday is 5 and this aligns with the PRT Notes