Oil daily problems

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #234333 quote
    Mr.Mjau
    Participant
    New

    Hi

    I have an algo that trades oil on a daily chart. I have this problem that oil is closed the hours 00:00-02:00 Tuesday-Friday, but my algo tries to take a position at 01:00 a clock which results in a error and that the algo shuts down. When I do backtest there is no problems but live it does not work. I tried the solution to limit the hours the algo can trade to not take a position before 02:00 but this results in 0 trades.

    There must be some easy fix that I am missing

    #234334 quote
    GraHal
    Participant
    Master

    Try below re the tradeon flag

    Once Tradeon = 1
    If Time > 000000 AND Time < 020000 Then
    Tradeon = 0
    else
    tradeon = 1
    Endif
    
    If BuyCondition AND Tradeon Then
    Buy at Market
    Endif
    #234335 quote
    druby
    Participant
    New
    #234336 quote
    Mr.Mjau
    Participant
    New

    Yes I have tried both solutions from @GraHal and @druby, and the result will be the same, the algo makes 0 trades. I have the same algo running on daily for naturalgas with no problems, as naturalgas dont have this 2h break between 00:00-02:00.

    #234337 quote
    GraHal
    Participant
    Master

    Aha my idea wont work on Daily TF anyway, because there will be no 1 hour bars for the condition Time > 000000 AND Time < 020000 to be true!

    #234338 quote
    druby
    Participant
    New

    I’m not up to speed in running algo’s, so this may be at bit of BS.

    I started scratching head when you mentioned, ‘Market closed’ and ‘ tries to take position’.

     

    @GraHal brings up a good point.

    If your algo is on daily, and lets say the code only action’s events at the close of a daily bar,

    then does that mean that even if the code recognised the market was in the closed area,

    it couldn’t action the change till the end of a bar, whereby the halt condition is no longer true.

    And therefore, setting an halt at the beginning of the day, and, with a change in the middle of the day, wouldn’t get actioned till the end of the day.

    Where it all repeats, possibly with no trades.

    This seems to explain while messing around with the time on daily, doesn’t give logical results regarding actions taken.

     

    Regarding , why it tries to take order when market shut, still scratching head.

    Unless you can make orders all the time, and get the error, if market shut.

    But, what made condition true…

    #234339 quote
    Mr.Mjau
    Participant
    New

    What I think is happening

    1 Algo only buys on the open of a new candle
    2 Algo thinks new candle opens at 01:00
    3 Market is closed 00:00-02:00 so impossible to make a trade

     

    Sidenote: Back in March when US started Summertime before us, Brent was closed 23:00-01:00 so the algo worked fine then

    Attachment
    Algo trying to get a position every second for about 5 min before giving up

    Mb found a work around, looks like US-Crude don’t have this 2h break or any break at all and should work to trade on the daily

    2024-06-25.png 2024-06-25.png
    #234341 quote
    druby
    Participant
    New

    All seems to fall into place!

    regards

    Mr.Mjau thanked this post
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Oil daily problems


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Mr.Mjau @mr-mjau Participant
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by druby
1 year, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/25/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...