Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with indicator

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

    Need help with indicator

    Hi ,
    I'm trying to develop my first indicator, but I'm doing wrong something and i do not understand where is the problem

    Basically when print out the value in order to check if is correct or not, i cannot see the decimal part of the division. (IB result) I can see just the integer value.

    below my code
    e
    protected override void OnBarUpdate()
    {
    if (Bars == null)
    return;


    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = Bars.BarsSeries.BarsType as
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

    if (barsType == null)
    return;


    try
    {

    IB[0]= ( barsType.Volumes[CurrentBar].Trades /barsType.Volumes[CurrentBar].TotalVolume );

    Print("IB: " + barsType.Volumes[CurrentBar].GetDeltaPercent());
    Print("Vol: " + (barsType.Volumes[CurrentBar].TotalVolume ));
    Print("Trade: " + (barsType.Volumes[CurrentBar].Trades));

    }
    catch{}
    }

    Thx
    Angelo


    #2
    Hello AngeloCiancia, thanks for your note.

    The volume values returned by volumetric bars are of type "long", this would truncate any decimals, so cast the calculation to type double and that should solve the issue:

    Value[0]= ((double)barsType.Volumes[CurrentBar].Trades/(double)barsType.Volumes[CurrentBar].TotalVolume);

    Kind regards.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    599 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    344 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    558 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    557 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X