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

truble with entering at first 4 bar od session

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

    truble with entering at first 4 bar od session

    Hi,

    I'm new at the programming at nt8 and I success to built some strategies with a big help from you.
    I have a problem: I built a strategy that check the first 4 bars of session and it's need to get long.
    When I run backtest everything was fine, when I check it on real time then I got no trades (few stocks should get the trade).
    what am I doing wrong?

    I really hope you can help me, I didn't sleep for two days....

    this is a part of the code:
    **I check the open of this day and the close of last day
    **time frame is minute


    private PriorDayOHLC priorDayClose;

    //instead the default at section of
    if (State == State.SetDefaults)
    BarsRequiredToTrade = 1;

    //in the section of
    else if (State == State.DataLoaded)

    priorDayClose = PriorDayOHLC();

    //part of the logic
    if (Bars.BarsSinceNewTradingDay == 3 && (Open[3] > priorDayClose.PriorClose[0] )

    //entry
    EnterLongLimit(250,GetCurrentBid());




    #2
    Hello assik,
    Thanks for your post.

    Are there any errors on the Logs tab of your Control Center? If so, what does the error say?

    What color is the strategy on your Strategiers tab whenever you are runnng it on realtime? (ie. Green, Orange, or Black)


    If you check the strategies historical performance when running on real-time do you see that it took any trades?


    What does TraceOrders report whenever you turn it on inside State.SetDefaults?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      Logs tab - I don't have any errors at the beginning, only after 10:00 (the strategy check the first bar, 9:00).
      color - green
      historical performance - yes, I see trades
      TraceOrders - I don't understand what it means. do you want me to add it to the strategy and check it tomorrow?

      Comment


        #4
        assik,

        It sounds like logic simply isnt executing the way you expect it to. Have you added Print() statements to your strategy and also confirmed on the chart that the strategy met the conditions for your entry? Can you show me the output from your Print()?


        I do suggest turning on TraceOrders anytime you need to debug your strategies orders. TraceOrders will let us track your orders to see if they are being placed, changed, rejected, etc. More information can be found inside the help guide link from my Post #2
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          I cant show you the output but I check it and the parameters works fine in the backtest.
          maybe I cant get to a position because of my order?
          can I send you my strategy?

          Comment


            #6
            assik,

            I would not be able to debug this script for you.

            A common issue that we see is that the strategy is taking some behaviors differently between historical and realtime data and all of the nuances behind strategy behaviors are not fully understood.

            If you are seeing your order submission logic being reached with your Print() statements, but it is not executing, there may be an issue where the strategy is already in a virtual position that is not allowing you to re-enter. TraceOrders can be enabled in the strategy so it prints its order feedback, and you may also observe the log tab of the Control Center for additional hints.

            Some items to check when you are taking debugging steps:
            1. Are your conditions allowing your order submission methods to be reached? You would use Print() to verify this.
            2. Is the strategy currently in a position that is preventing it from submitting another entry order?
            3. Do you see any errors in the log tab of the Control Center or does Trace Orders give you any feedback?
            I am happy to help intrepet any oputput you receive during your debugging.

            Below are links to documentation resources that further explain Discrepancies between Historical and Realtime data, Start Behaviors, and the internal rules of the Managed Approach.

            Discrepancies between historical and Realtime data - https://ninjatrader.com/support/help...ime_vs_bac.htm
            Start Behaviors - https://ninjatrader.com/support/help..._positions.htm
            Managed Approach (Internal Rules) - https://ninjatrader.com/support/help...antedPositions
            Strategy Position vs. Account Position - https://ninjatrader.com/support/help..._account_p.htm
            Josh G.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by warreng86, 11-10-2020, 02:04 PM
            6 responses
            1,357 views
            0 likes
            Last Post mathewlo  
            Started by Perr0Grande, Today, 08:16 PM
            0 responses
            3 views
            0 likes
            Last Post Perr0Grande  
            Started by elderan, Today, 08:03 PM
            0 responses
            5 views
            0 likes
            Last Post elderan
            by elderan
             
            Started by algospoke, Today, 06:40 PM
            0 responses
            10 views
            0 likes
            Last Post algospoke  
            Started by maybeimnotrader, Today, 05:46 PM
            0 responses
            12 views
            0 likes
            Last Post maybeimnotrader  
            Working...
            X