Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by helpwanted, Today, 03:06 AM
    1 response
    11 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    9 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    387 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X