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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    44 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    56 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    35 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    95 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    57 views
    0 likes
    Last Post PaulMohn  
    Working...
    X