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

Check P&L for each tick inside a Strategy executing at the close of each bar

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

    Check P&L for each tick inside a Strategy executing at the close of each bar

    Hi,

    (Two questions)

    1)
    I have a strategy with logic that executes at the close of each bar. It initiates ATM Orders based on certain conditions.

    This strategy also has to track current Profit&Loss (e.g. the day's Realized + Unrealized P&L) constantly - with each tick, so that the drawdown within each bar never violates certain limits. In other words, just this portion of the code needs to be executed with each tick, while the rest of the strategy executes at the end of each bar. How can this be accomplished..?

    2) A corollary...:
    - If I have a strategy that's set to execute On Each Tick, then, how can I add code to that Strategy (assume it's unlocked), that executes only at the close of a bar..?

    Thank you for your advice and assistance.

    Regards,

    RK
    Last edited by rasdaka; 10-23-2022, 06:21 PM.

    #2
    Hello RK,

    Thanks for your post.

    Yes, logic can be separated between Calculate.OnEachTick and Calculate.OnBarClose using IsFirstTickOfBar.

    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

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jpeep, 08-16-2020, 08:31 AM
    17 responses
    502 views
    0 likes
    Last Post notenufftime  
    Started by ETFVoyageur, 05-07-2024, 07:05 PM
    15 responses
    124 views
    0 likes
    Last Post ETFVoyageur  
    Started by esmall, Today, 07:14 PM
    0 responses
    9 views
    0 likes
    Last Post esmall
    by esmall
     
    Started by Option Whisperer, 05-09-2024, 07:58 PM
    6 responses
    26 views
    0 likes
    Last Post Option Whisperer  
    Started by rayyyu12, Today, 05:38 PM
    0 responses
    12 views
    0 likes
    Last Post rayyyu12  
    Working...
    X