Don’t want sundays to be shorn/counted

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #243133 quote
    dubbzie
    Participant
    New

    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?

    #243135 quote
    Anjuna Marine
    Participant
    New

    I’ve run into this same issue and found the best approach is to adjust the code so Sundays are completely ignored. For example:

    IF OpenDayOfWeek > 0 AND OpenDayOfWeek < 6 THEN

    // Your trading conditions and execution logic here

    ENDIF

    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!

    Iván González, dubbzie and robertogozzi thanked this post
    #243156 quote
    dubbzie
    Participant
    New

    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.

    #243161 quote
    robertogozzi
    Moderator
    Master

    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.

    dubbzie and Iván González thanked this post
    #243168 quote
    dubbzie
    Participant
    New

    Thank you very much, robertogozzi! You don’t happen to have a formula calculating RSI without  sundays?

    #243189 quote
    robertogozzi
    Moderator
    Master

    Yes, I’ll code it asap 🙂

    dubbzie thanked this post
    #243196 quote
    dubbzie
    Participant
    New

    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.

    #243402 quote
    robertogozzi
    Moderator
    Master

    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.

    PeterSt and dubbzie thanked this post
    #243489 quote
    dubbzie
    Participant
    New

    Ok, thank you very much for trying!🙏

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Don’t want sundays to be shorn/counted


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
dubbzie @dubbzie Participant
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by dubbzie
1 year ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 01/27/2025
Status: Active
Attachments: No files
Logo Logo
Loading...