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

forcing bar closes and price changes

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

    forcing bar closes and price changes

    How can I run my strategy on a price change basis but trick the entry reason into being on bar close?
    Surely there has to be a way? thanks

    #2
    Hello ezrollin,

    Thanks for your post.

    Yes, logic can be separated between Calculate.OnPriceChange 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 OnPriceChange 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. In your script, you would use Calculate.OnPriceChange instead of Calculate.OnEachTick.

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

    You will set your host script to Calculate.OnPriceChange 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 OnPriceChange outside of the IsFirstTickOfBar condition check.


    Please let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by naanku, Today, 07:25 PM
    0 responses
    2 views
    0 likes
    Last Post naanku
    by naanku
     
    Started by milfocs, Today, 07:23 PM
    0 responses
    1 view
    0 likes
    Last Post milfocs
    by milfocs
     
    Started by PaulMohn, Today, 06:59 PM
    0 responses
    5 views
    0 likes
    Last Post PaulMohn  
    Started by bortz, 11-06-2023, 08:04 AM
    48 responses
    1,748 views
    0 likes
    Last Post carnitron  
    Started by Jonker, 04-27-2024, 01:19 PM
    3 responses
    23 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X