Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Strategy question.

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

    Custom Strategy question.

    This is something I have found that I need to see is possible. I have a strategy where I am using a multi-chart setup. 2min and 10min. I have nearly everything setup but I need one thing figured out that I'm really hoping Ninjatrader can do.

    Is there a way to have one indicator use 'On Tick change' and another one that uses 'On Bar close'?

    So for instance I have one indicator that determines the trend strength but I don't want it to be updated with 'On Tick change' but instead 'On Bar close' and then I have an EMA crossover that I have set to 'On tick change'

    So the issue I'm running into is when you enable the strategy you can only choose 'On Bar close', 'On tick change', or 'On Price Change'. This is great if ALL my indicators were just using that setup but I need it to be where its specific to the indicator.

    Please tell me this is possible some how.

    #2
    Hello vegas3416,

    Thank you for your post.

    Yes, logic can be separated between Calculate.OnEachTick and Calculate.OnBarClose using IsFirstTickOfBar. Please note that a hosted script will inherit the Calculate mode of the script that hosts it. You can take the following approach to differentiate logic between OnBarClose and OnEachTick processing.

    Please see this reference sample which demonstrates a technique used for those who need to separate their logic to calculate some values on each tick and others only on the close of a bar. You will set your host script to Calculate.OnEachTick and use if(IsFirstTickOfBar) and place all code that needs to calculate once every bar within that condition check. Then place all code that you want to calculate OnEachTick outside of the IsFirstTickOfBar condition check.

    SampleEnterOnceExitEveryTick -https://ninjatrader.com/support/help...either_cal.htm

    Please let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Awesome!! Exactly what I need. Haven't looked at link fully yet but based on what you are saying here this is exactly what I need to do. Wish I could do it in the strategy builder but this works as well. Thanks again!!

      Comment


        #4
        That Sample code that is on that link is broken. Do you have another link that goes to the sample code?

        Comment


          #5
          Hello vegas3416,

          Thank you for your note.

          Here is the correct link to the SampleEnterOnceExitEveryTick example script: https://ninjatrader.com/support/help...either_cal.htm

          Let us know if we may assist further.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Originally posted by NinjaTrader_BrandonH View Post
            Hello vegas3416,

            Thank you for your note.

            Here is the correct link to the SampleEnterOnceExitEveryTick example script: https://ninjatrader.com/support/help...either_cal.htm

            Let us know if we may assist further.


            Yeah the link works but there is a ZIP file on that link but it does not work when you click on it. I am looking for the zip file not the link to the forum. Sorry if I worded that incorrectly.

            Comment


              #7

              Hi Vegas,

              Saw your post here and on FIO as well.


              Originally posted by vegas3416 View Post
              Yeah the link works but there is a ZIP file on that link but it does not work when you click on it. I am looking for the zip file not the link to the forum. Sorry if I worded that incorrectly.

              Just posting to say the link above and pasted in below worked fine several times to pull down the zip file.
              On my machine, downloading the same shows up in a new Windows Explorer (File Manager) instance rather than Browser downloads. Also the file appears in my Downloads directory.


              " https://ninjatrader.com/support/help...ryTick_NT8.zip "


              HedgePlay

              Comment


                #8
                I must have some settings on. I had to open link in a 'cognito' web page for it to download. Otherwise if I just click on it the link sends me to a German site of Ninjatrader, but I got it now. Appreciate it. Must be a setting I have on Chrome.

                Side note - Do you know how to show two data series on the strategy and be able to color or put an exact price marker when it hits on both? I know you can just run the strategy and the chart tab will show the shorts and longs but I just want to put a drawing tool maybe like an arrow to the right of the point where a trigger hits with the text of the price it hit at.

                Comment


                  #9
                  Hello vegas3416,

                  Thank you for that information.

                  Adding secondary data series to your strategy would be accomplished using AddDataSeries(). Please note that to show both data series used in your strategy, you would need to either add the secondary series to the same chart as the primary series or open a new chart for the secondary data series.

                  See the help guide documentation for AddDataSeries() for more information.
                  AddDataSeries - https://ninjatrader.com/support/help...dataseries.htm

                  Referencing the added secondary series would be done using a BarsInProgress check. The primary data series of your script will be BarsInProgress 0 and the secondary series will be BarsInProgress 1.

                  See this link for more information about BarsInProgress - https://ninjatrader.com/support/help...inprogress.htm

                  Also, see this link regarding working with multi-timeframe and multi-instrument scripts - https://ninjatrader.com/support/help...nstruments.htm

                  Drawing an arrow when a certain condition becomes true for both data series would be done by using Draw.ArrowUp(). You could also draw text by using the Draw.Text() method to draw the price that the condition becomes true.

                  See the help guide links below about the Draw.ArrowUp() and Draw.Text() methods.
                  Draw.ArrowUp() - https://ninjatrader.com/support/help...aw_arrowup.htm
                  Draw.Text() - https://ninjatrader.com/support/help.../draw_text.htm

                  Let us know if we may assist further.
                  <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  581 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  338 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  103 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  554 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  552 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X