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 gbourque, Today, 06:39 AM
    0 responses
    2 views
    0 likes
    Last Post gbourque  
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by benmarkal, Yesterday, 12:52 PM
    3 responses
    23 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    20 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    12 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Working...
    X