Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by gm7_forum, Today, 05:51 PM
    0 responses
    2 views
    0 likes
    Last Post gm7_forum  
    Started by cre8able, Today, 03:20 PM
    1 response
    9 views
    0 likes
    Last Post cre8able  
    Started by fiddich, Today, 05:25 PM
    0 responses
    3 views
    0 likes
    Last Post fiddich
    by fiddich
     
    Started by gemify, 11-11-2022, 11:52 AM
    6 responses
    804 views
    2 likes
    Last Post ultls
    by ultls
     
    Started by ScottWalsh, Today, 04:52 PM
    0 responses
    4 views
    0 likes
    Last Post ScottWalsh  
    Working...
    X