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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X