Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

get the value of a bar in $.

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

    get the value of a bar in $.

    Hello
    I'm trying to get the value of a bar ( Close - Open) in $.
    I searched for information in the doc and came up with a script that doesn't satisfy me.
    I missed something but I don't know what or where to find it.
    (I think it's the lot size, but is this info accessible by code in NT8?)
    If one of you could take a look at my code and tell me what's wrong.
    Thank you in advance.​

    Code:
    double ValeurDuTick =  TickSize;
                Print("Tick Value " +ValeurDuTick.ToString());
    
                double value = 1/TickSize;
                Print("TickSize " + value);
    
                Print("Open " + Open[1]);
                Print("Close " + Close[1]);
                value =Close[1] -Open[1];
                Print("Value in points " + value);
    
                value =value / TickSize;
                Print("Value in ticks " + value);
    
                value =value* ValeurDuTick;
                Print("Value in $ " + value);​
    The result
    Tick Value 0,015625
    TickSize 64
    Open 109,453125
    Close 109,671875
    Value in points 0,21875
    Value in ticks 14
    Value in $ 0,21875​​​​

    #2
    Hello stephletrader,

    Thank you for your post.

    You could use PointValue to get the currency value of 1 point:


    You could then get the value of a tick by multiplying the point value by TickSize. Finally, you could find the difference between the Open and Close in ticks and multiply that by the tick value. Here is an example:
    Code:
    double tickValue, barTicks;
    
    // calculate the value per tick
    tickValue = Bars.Instrument.MasterInstrument.PointValue * TickSize;
    
    // calculate the size of the previous bar in ticks
    barTicks = Math.Abs(Open[1] - Close[1]) / TickSize;
    
    Print("The value of the previous bar is: " + (tickValue * barTicks));
    Please let us know if we may be of further assistance.

    Comment


      #3
      Thank you, it's perfect. I think I was getting a little complicated :-)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      637 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      571 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X