Announcement

Collapse
No announcement yet.

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.​
    <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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    54 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
    71 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
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X