Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Excecute OnPriceChange and OnBarClose in the same strategy

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

    Excecute OnPriceChange and OnBarClose in the same strategy

    Hello.
    I need to excecute distinct methods in the same strategy but one method needs to excecute onPriceChange and other method needs to excecute OnBarClose.
    Is that possible?
    I am developing on ninjascript
    Thank you

    #2
    Hello fscabrera03,

    Thank you for your post.

    Logic could be separated in your script to run OnPriceChange or OnBarClose by 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. Instead of using OnEachTick like the example, you would use OnPriceChange to have some values calculate on price change. 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.

    See the SampleEnterOnceExitEveryTick example in the help guide documentation below for more information.
    SampleEnterOnceExitEveryTick - https://ninjatrader.com/support/help...either_cal.htm

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rdtdale, Yesterday, 01:02 PM
    2 responses
    15 views
    0 likes
    Last Post rdtdale
    by rdtdale
     
    Started by TradeSaber, Today, 07:18 AM
    0 responses
    7 views
    0 likes
    Last Post TradeSaber  
    Started by PaulMohn, Today, 05:00 AM
    0 responses
    9 views
    0 likes
    Last Post PaulMohn  
    Started by ZenCortexAuCost, Today, 04:24 AM
    0 responses
    6 views
    0 likes
    Last Post ZenCortexAuCost  
    Started by ZenCortexAuCost, Today, 04:22 AM
    0 responses
    3 views
    0 likes
    Last Post ZenCortexAuCost  
    Working...
    X