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

Calculate third of the bar?

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

    Calculate third of the bar?

    What is the suggested sysinct way to code that condition that if close[0] < then third of the body of previous bar then no trade? I know the long way but was wondering if there is a short way?
    Thank you


    Click image for larger version

Name:	image.png
Views:	63
Size:	65.0 KB
ID:	1253222

    #2
    Hello, thanks for writing in.

    Heres how you would find one third of the bar:

    1. Find the difference between the opening and closing prices of the bar. Let's call this difference "D." var D = (Open[1] - Close[1])

    2. Divide D by 3 to calculate one-third of the price range: var OneThird = D / 3.

    3. If the opening price is higher than the closing price, subtract OneThird from the closing price to find the one-third point within the bar. This represents the distance from the closing price towards the opening price.

    Example: var OneThirdPoint = Close[1] - OneThird.

    4. If the closing price is higher than the opening price, add OneThird to the closing price to find the one-third point within the bar. This represents the distance from the opening price towards the closing price.

    Example: var OneThirdPoint = Close[1] + OneThird.​
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by tkaboris View Post
      What is the suggested sysinct way to code that condition that if close[0] < then third of the body of previous bar then no trade? I know the long way but was wondering if there is a short way?
      Thank you


      Click image for larger version  Name:	image.png Views:	35 Size:	65.0 KB ID:	1253222
      Hello @tkaboris,
      I'm using a similar indicator showing quarter points per candle so I appreciate your question about the one-third data. Please tell us what the gold and blue indicator settings are. I'm curious why the "dogleg" occurred in the gold one. Thanks.
      Last edited by zeller4; 08-14-2023, 12:31 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Trader146, Today, 11:41 AM
      0 responses
      2 views
      0 likes
      Last Post Trader146  
      Started by jpapa, 04-23-2024, 07:22 AM
      2 responses
      16 views
      0 likes
      Last Post rene69851  
      Started by funk10101, Today, 11:35 AM
      0 responses
      1 view
      0 likes
      Last Post funk10101  
      Started by samish18, Today, 11:26 AM
      0 responses
      1 view
      0 likes
      Last Post samish18  
      Started by Trader146, 03-29-2024, 01:22 PM
      2 responses
      14 views
      0 likes
      Last Post Trader146  
      Working...
      X