Hi,
Not sure if this has been posted in the right place?
I am trading US Tech1 100 CFD with automated strategies using ProRealTime on the web. The issue is: Sundays are appearing and included in the calculation of indicators, and trades can be made on Monday at 01:00 based on Sunday’s calculations. I only want Monday through Friday to be included… Is there anything I can do to achieve that?
I’ve run into this same issue and found the best approach is to adjust the code so Sundays are completely ignored. For example:
You’ll also need to modify any indicators that span multiple days. For instance, for a 200-period moving average, you’d adjust to account for extra Sunday bars (e.g., use Average[240] instead of Average[200] when working with daily charts).
It’s safer and more robust to handle this in your code rather than rely on a workaround that depends on compatibility between ProRealTime and your broker. I also find it frustrating to see a daily bar for Sunday on platforms like IG when the market has only been open for a couple of hours. It throws off both visual analysis and indicator calculations.
If anyone else has tips or alternative solutions, I’d love to hear them!
Thank you very much. It solves how not to trade on Sunday, but how to remove Sundays from, for example, RSI calculations? Any suggestions? It’s strange that on the IG App sundayg are remowed, but not in the ProRealCode web-solution. If it would be possible to use data from IG App or IG web platform, the problem would be solved.
Based on this indicator of mine at https://www.prorealcode.com/prorealtime-indicators/time-range-moving-averages-simple-exponential-weighted-trsma-trema-trwma/, I modiefied the TREMA to adapt it to days of the week, instead of times (but the two solutions could be easily combined):
// DayOfWeek EXPONENTIAL MOVING AVERAGE
//
Periods = 20
//
Alpha = 2 / (Periods + 1)
i = 0
dowEMA = close
FOR j = 0 TO 3000
IF OpenDayOfWeek[j] >= 1 AND OpenDayOfWeek[j] <= 5 THEN
i = i + 1
dowEMA = ((close[j] - dowEMA) * Alpha) + dowEMA
IF i = Periods THEN
BREAK
ENDIF
ENDIF
NEXT
IF dowEMA = 0 THEN
dowEMA = close
ENDIF
Return dowEMA AS "dowEMA"
There’s no way to have default indicators adapted. Each desired indicator of which the source code (or at least its formula) is known coud be tested and probably adapted, but this ios not 100% guaranteed and is for sure time consuming.
Thank you very much, robertogozzi! You don’t happen to have a formula calculating RSI without sundays?
Thanks – I really appreciate it, and I’m sure many others do too! I trade using the 2-day RSI strategy, and it’s critical that the RSI is accurate.
Sorry dubbzie, but while it’s fairly easy with some MAs (not all of them), with RSI (and most indicators), it’s quite complicated, instead. After a whole day spent with arrays and iterations I couldn’t achieve any result!
It’s complicated because when calulating the selected days for the RSI, I must take into account that its single daily value depends on the WilderAverage which, in turn, has to be calculated on the same selected days… moreover the two indicators may have different periods and require nested FOR..NEXT loop which may lead to errors.
Ok, thank you very much for trying!🙏