Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A good pure bars only intragranular/ mtf example needed

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

    A good pure bars only intragranular/ mtf example needed

    I have seen a few examples of MTF here and there but they are all indicator based. I am working on some strategies where I jneed to be able to exit trades intrabar or at the very close of the same bar a trade was entered in. I just want one good example of a MTF strategy that uses only the bars logic for entries and exits, after that I should be able to go on from there. Please dont say read the documentation and provide a link as I have been reading them for days. I just need to see one solid example of a strategy using no indicators that enters and exits the same bar and doesnt take more than one trade during that bar, The logic can be as simple as this code piece which is extracted from one of my flawed attempts in trying to solve how to enter and exit on the same bar.
    if (Close[0] < Open[0])
    {
    EnterLong(1, 1, "Long Entry"); // order submitted to BarsInProgress 1
    }
    }

    // Exit logic
    if (Position.MarketPosition == MarketPosition.Long && BarsInProgress == 1 && IsFirstTickOfBar)
    {
    ExitLong("Exit Long", "Long Entry");
    }

    Thanks Quantismo

    Any help is appreciated!​

    #2
    Hello quantismo,

    Thank you for your post.

    What functionality are you looking for with the multiple time frames? Is your added data series a 1-tick series?

    To execute trades intrabar, you can change the calculate setting to OnEachTick or OnPriceChange.

    https://ninjatrader.com/support/help.../calculate.htm

    What calculate setting are you using? Are you testing this in real-time or in backtest/historical?

    If in historical, have you enabled tick replay?

    Your condition that checks IsFirstTickOfBar will make sure the position is only exited on the first tick of a new bar, so it will prevent exits from being able to happen on the same bar you entered in.

    I look forward to assisting further.
    Last edited by NinjaTrader_Gaby; 04-18-2024, 07:36 AM.

    Comment


      #3
      I did have an added 1 tick series not show in the code above. If Anyone else is able to provide an actual example of what I asked for and not another link would be extreemly helpful.

      Comment


        #4
        Hello quantismo,

        Please see the attached sample script. It allows for entries and exits to happen intrabar, and limits entries to once per bar. Note that TickReplay should be enabled for this to work historically.

        Please let us know if this doesn't guide you in the right direction.
        Attached Files

        Comment


          #5
          My original post stated "Please dont say read the documentation and provide a link as I have been reading them for days. I just need to see one solid example of a strategy using no indicators that enters and exits the same bar and doesnt take more than one trade during that bar." AGAIN! I have read all those links you keep providing. Please no more links! Ninjatrader 8 has a MTF example that comes already installed when you download the platform. I am just asking for a example code for MTF/ INTRABAR that uses only bars like shown in my first post, not based on indicators that can be run on any type of chart like and hourly, range , tick etc.

          Thanks Quantismo

          Comment


            #6
            quantismo,

            That is not a link. Please take another look at my post and read it. It's a .zip file containing a strategy script. My comment says "please see the attached sample script".
            Last edited by NinjaTrader_Gaby; 04-19-2024, 11:42 AM.

            Comment


              #7
              I appreciate the code example you provided Gaby! I however have tried testing its funtionality on Live, playback and simulation mode. With tick replay and without tick replay and no matter what the code code logic intended in the script is being negated somehow and its just fireing entries and exits on every single candle. Am i missing somthing? If you could test the script on your machine to make sure there isnt some error i would appreciate it.

              Thanks Quantismo

              Comment


                #8
                Hello quantismo,

                As per your request, the code demonstrates being able to enter/exit intrabar (using Calculate.OnEachTick) and limit the entries to once per bar (using a bool called IsOkToTrade).

                I just need to see one solid example of a strategy using no indicators that enters and exits the same bar and doesnt take more than one trade during that bar
                If you don't want the script to enter on every single bar, you can just adjust the entry conditions with your own custom logic to limit when the entry is taken.

                The "Closes[0][0] greater than/less than Opens[0][0]" logic is just the entry and exit conditions I came up with, but you can edit these to suit your needs.

                The important part is to check for the IsOKToTrade bool in the entry condition, then set the bool to false after entering to limit your entries to once per bar.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                52 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                130 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                70 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                44 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                48 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X