Trading every 10. days of the month

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #177413 quote
    SuffiSuffi
    Participant
    Junior

    Hello Roberto,
    thanks for the code, unfortunately I get errors again on exit.
    The trade is often closed 2 months later.
    TF 15 min.

    greetings
    Suffi

    //-------------------------------------------------------------------------
    // Suffi TF 15 min
    //-------------------------------------------------------------------------
    DEFPARAM PreLoadBars = 1000
    BuyTime  = 0
    SellTime = 0
    IF (Day = 5) or ((Day > 5) and (Day[1] < 5)) THEN
    SellTime = 1
    ENDIF
    IF (Day = 26) or ((Day > 26) and (Day[1] < 26)) THEN
    BuyTime = 1
    ENDIF
    
    IF NOT LongOnMarket AND BuyTime AND CurrentTime >=90000 THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    IF LongOnMarket AND SellTime AND CurrentTime >=200000 THEN
    SELL AT MARKET
    ENDIF
    
    Unbenannt.png Unbenannt.png
    #177448 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    The code detects the selcted DAY when the chosen number is equal to a trading day OR when it wasn’t a trading day.

    But at 00:00 the system does NOT change the day (it is still the old day till 01:00am), so when the day changes, if it’s not exactly the chosen day, the day change is not recognized because DAY > YourDay, but DAY[1] is NOT < YourDay!

    This is the modified code:

    //-------------------------------------------------------------------------
    // Suffi TF 15 min
    //-------------------------------------------------------------------------
    DEFPARAM PreLoadBars = 1000
    ONCE BuyTime  = 0
    ONCE SellTime = 0
    IF Month <> Month[1] THEN
       BuyTime  = 0
       SellTime = 0
    ENDIF
    IF (Day = 5) or ((Day > 5) and (Day[1] < 5)) AND LongOnMarket THEN
       SellTime = 1
    ENDIF
    IF (Day = 26) or ((Day > 26) and (Day[1] < 26)) AND Not LongOnMarket THEN
       BuyTime = 1
    ENDIF
    IF NOT LongOnMarket AND BuyTime AND CurrentTime >=90000 THEN
       BUY 1 CONTRACTS AT MARKET
       SellTime = 0
    ENDIF
    IF LongOnMarket AND SellTime AND CurrentTime >=200000 THEN
       SELL AT MARKET
       BuyTime = 0
    ENDIF
    //graph SellTime
    //graph BuyTime
    //graph Day
    //graph CurrentTime
    //graph DayOfWeek
    #177469 quote
    SuffiSuffi
    Participant
    Junior

    Hello Roberto,
    great and thank you very much, now it works fine.

    Greetings
    Suffi

Viewing 3 posts - 16 through 18 (of 18 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Trading every 10. days of the month


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Suffi @suffi Participant
Summary

This topic contains 17 replies,
has 2 voices, and was last updated by SuffiSuffi
5 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/09/2021
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...