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

How do you compare the size of the bar body?

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

    How do you compare the size of the bar body?

    Hi. I am new to programming.
    I have this code:

    Value.Set (Math.Abs (Open [0] -close [0]));

    It gives me the size of the body of the candle.

    I want that if the value is greater than 10 (the body of the candle that gives me value.Set) other code is executed.

    I do this:

    if (value.Set (Math.Abs (Open [0] -close [0])))> 10)
    BarColor = Color.Blue;

    fails. He says he does not support>
    If you use a variable also fails.

    Thank you.

    #2
    Hello julifro,

    Thanks for your post.

    I would keep the Value.Set out of the if() statement.

    This will compile:

    Value.Set (Math.Abs (Open [0] - close [0]));

    if (Value[0] > 10)
    BarColor = Color.Blue;
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      How could one measure the wicks of the top of the bar versus the bottom and display which is greater?

      upBarTopWick
      Value.Set(Math.Abs(High[0]-Close[0]);
      upBarBottomWick
      Value.set(Math.Abs(Open[0]-Close[0]);

      Which value is greater, top of bottom?


      downBarTopWick
      value.set(Math.Abs(High[0]-Open[0]);
      downBarBottomWick
      Value.set(Math.Abs(Close[0]-Low[0]);


      Which value is greater, top of bottom?



      Any suggestions on where to go with this, I want to look over the past n bars as well to see the change in wicks
      Last edited by brucelevy; 03-11-2016, 02:19 PM.

      Comment


        #4
        Hello brucelevy,

        Thanks for your post.

        You would use if (Condition-A) {Action-A} else {Action -B}

        if ((Math.Abs(High[0]-Close[0])) > (Math.Abs(Open[0]-Low[0]))
        {
        Value.Set(Math.Abs(High[0]-Close[0]);
        }
        else
        {
        Value.set(Math.Abs(Open[0]-Low[0]);
        }

        In the above example, you check if the top wick is greater than the bottom wick and if it is then plot the distance of the top wick, if it is not greater than plot the bottom wick.

        You will need to decide how you want to resolve when they are equal or non existent.

        Please review the helpguide on Branching here: http://ninjatrader.com/support/helpG...g_commands.htm
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by junkone, Today, 11:37 AM
        2 responses
        14 views
        0 likes
        Last Post junkone
        by junkone
         
        Started by frankthearm, Yesterday, 09:08 AM
        12 responses
        44 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by quantismo, 04-17-2024, 05:13 PM
        5 responses
        35 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by proptrade13, Today, 11:06 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        35 views
        0 likes
        Last Post love2code2trade  
        Working...
        X