Hi Guys n Gals
Just a quick check on logic here as the code below is opening trades on weekends Sunday evening, which I would rather avoid due to spreads. Should I remove the “and not”? I did send a query on it to PRT via help with no reply yet.
DEFPARAM CumulateOrders = false
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0//dont trade Saturday and Sunday
IF not onmarket and c1 AND not daysForbiddenEntry and result1 <1 And indicator7>=25 THEN
BUY myamount PERPOINT AT MARKET
ENDIF
You don’t say what time frame you are running the strategy on. The code will allow trades to open from midnight at the end of Sunday. If you are on a daily chart then as all decisions are made at the close of a candle then this is what will happen. If you are on a faster time frame and want trades to open only after a specific hour on Monday then you have to tell your strategy that this is what you want.
This will let you select days and different times each day, overnight or not https://www.prorealcode.com/topic/time-and-day-conditions/.
You don’t say what time frame you are running the strategy on. The code will allow trades to open from midnight at the end of Sunday. If you are on a daily chart then as all decisions are made at the close of a candle then this is what will happen. If you are on a faster time frame and want trades to open only after a specific hour on Monday then you have to tell your strategy that this is what you want.
OK thanks. All my strategies run on 7hrs or 4hrs currently, also 9hrs previously. I assumed as it was from the inbuilt program coding that it wouldnt trade on Sat / Sunday. I can see a need ot code it in though, so will take alook at the code Robert refers to and try out…
This will let you select days and different times each day, overnight or not https://www.prorealcode.com/topic/time-and-day-conditions/.
Cheers. Yes I now recall I’ve seen that somewhere in code here on the forum. I can see a need to code it in, but assumed it should work if from the simple programming code. I’ll take a look at that and see how it does. Thanks… It will be a stock paste into all code for weekend.. 🙂
but assumed it should work if from the simple programming code.
Maybe it would if you used CurrentDayOfWeek (not opendayofweek)?
I did think it might be related to timezone, I think it may have been the Dax, but that’s the same timezone as me which is London. I’ll see how the code fairs..
but assumed it should work if from the simple programming code.
Maybe it would if you used CurrentDayOfWeek (not opendayofweek)?
Thanks GraHal
Yes that actually makes sense, though bearing in mind timezone for the instrument. May be worth a try if I just want to blanket Sat/Sunday easily
donttrademe = currentdayofweek=0 or currentdayofweek=6
If not onmarket and myconditions and not donttrademe then
..
Endif
or if it still doesnt do maybe try
trademe = currentdayofweek=1 or currentdayofweek=2 or currentdayofweek=3 or currentdayofweek=4 or currentdayofweek=5
If not onmarket and myconditions and trademe then
..
Endif