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