Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Execute trades on a daily chart at another time than close

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Execute trades on a daily chart at another time than close

    I want to be able to execute a trade on a daily chart once a day, but not at the close of the daily bar. I want to be able to do it an hour before close, or an hour after close.

    I'm aware of AddDataSeries() and I guess I could add an hourly series and then somehow wait for the time of that series before executing the trade. However, I still want all my indicators, etc, to use the daily chart bars, but at the time of the trade and not at the actual daily chart close. So basically I think I will have to create my own daily chart bars where I'm actually moving the close time of the bars 1 hour (at least I think this is how it could be done).

    Do you guys have an example of something like this that might help me get a start?

    #2
    Hello linuxguru,

    You are correct with AddDataSeries, you could add a smaller timeframe series to execute some logic at that frequency. This is standard for multi series scripts, generally you use the BarsInProgress property to know what series called OnBarUpdate to know how to delegate your logic. You can read about this concept in the following page:



    If you wanted to make the indicators use the daily bars specifically you could have them reference the primary series when you call them. That may look similar to the following:

    Code:
    double sma = SMA(BarsArray[0], 12)[0];
    That ensures if you call it from the secondary BarsInProgress you are still referencing the primary series indicator. Not all indicators work this way, you would need to check the indicator in question to see if it uses Input in its code to know if it could be passes a series. If it cannot you would otherwise need to call it in the BarsInProgress:

    Code:
    private double mySma = 0;
    protected override void OnBarUpdate()
    {
    if(BarsInProgress == 0)
    {
    mySma = SMA(12)[0]; 
    }
    if(BarsInProgress == 1)
    {
        Print(mySma)
    }
    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    116 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    61 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    40 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    43 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    82 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X