• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Closing time

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

    Closing time

    Hello!
    I wrote schedules when the order should be closed! that is, time to exit the market.
    question where to put this code ??

    if((exitSesion1 && ToTime(Time[0]) >= end_time && ToTime(Time[0]) <= start_time_1) || (exitSesion2 && ToTime(Time[0]) >= end_time_1 && ToTime(Time[0]) <= start_time_2))
    {
    ExitLong();
    ExitShort();
    CancelOrder(entryOrder1);
    CancelOrder(entryOrder2);
    }

    OnBarUpdate is not correct as the work on closing the bar and the strategy works a long interval or long renko

    #2
    Hello oscsoft,

    OnBarUpdate would generally be where this type of logic would go, you could also use the other overrides like OnMarketData to have this checked for incoming realtime data. If the reason this cannot go in OnBarUpdate is due to the interval or bars type being used you could make a multi series strategy which has a more granular secondary series such as 10 seconds. That would allow you to execute some logic every 10 seconds and other logic at the rate of the renko.

    https://ninjatrader.com/support/help...lightsub=multi

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for the answer !
      honestly, I did not quite understand how to implement this!
      But can I see an example of the implementation of this issue? using an example of a simple strategy.

      thanks

      Comment


        #4
        Hello

        You can see an example of the OnMarketData override here: https://ninjatrader.com/support/help...b=OnMarketData
        OnMarketData is called for market data events, you could execute that code from that override if you wanted to break away from the renko series and OnBarClose. That would only work in realtime so if you need to backtest the strategy this likely is not the best solution as TickReplay would be required.

        Otherwise for an example of a multi series strategy you can see the SampleMultiInstrument or SampleMultiTimeFrame strategies that come with NinjaTrader. Because this is a more complicated subject I would suggest to read the multi series documentation to better understand using multiple series to control logic: https://ninjatrader.com/support/help...lightsub=multi

        After adding a secondary series you would execute the code you had provided from a BarsInProgress condition:

        Code:
        if(BarsInProgress == 1)
        {
        
        }


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by waterman, Today, 07:02 PM
        0 responses
        1 view
        0 likes
        Last Post waterman  
        Started by authenticx, Today, 03:51 PM
        0 responses
        12 views
        0 likes
        Last Post authenticx  
        Started by PN720, Today, 12:54 PM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Jim  
        Started by linuxguru, Yesterday, 05:59 PM
        1 response
        30 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by xasser, Today, 02:17 PM
        3 responses
        40 views
        0 likes
        Last Post xasser
        by xasser
         
        Working...
        X