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

Using indicator from ES on Currency Futures Chart

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

    Using indicator from ES on Currency Futures Chart

    Hello,

    I have an indicator which when I place it on an ES chart, produces a crossover of a red and blue line in a kind of curving pattern. The scale is justified to the left and generally runs from -1 up to +8. You can see it in panel 1 of the attached image (ES with Indicator). In the third panel of the image is the same indicator, but used only once this time, and with a longer period, and again it curves up and down.

    When I put this indicator on a currency futures chart – GBP/USD (6B) – see image attached, it results in flat lines or thin towers (in panels 1 & 3), which really give no information. It seems it may be because the scale justification on the left has jumped from -1 to 8 on the ES to as high as 75000M on the currency futures chart. Is there a standard way of adjusting this type of indicator which works on an ES chart so that it works on a currency futures chart?

    Thank you.
    Attached Files

    #2
    Hello GeorgeW, and thank you for your question.

    The underlying problem here is that you have some data with very large numbers, and some data with very small numbers. If you try to display both at the same time, you get what you observed. The choice you have to make as a programmer, then, is whether or not you filter out data, so you are only looking at data with small numbers, or if you want to change your data so that, as numbers get bigger and bigger, it gets harder and harder for a difference to show up in your plot.

    Filtering out high values is trivially easy, but for completeness, you can do it like this :
    Code:
    [FONT=Courier New]if (Close[0] > filterValue) return;[/FONT]
    One standard way of doing the second thing is to use a logarithmic function. The easiest way to explain these without using too much in the way of math is with an example. If we use a base 10 logarithm, then we can take this sequence and count the zeroes to get the output value, that is

    log10(1) = 0
    log10(10) = 1
    log10(100) = 2
    log10(1000) = 3
    log10(10000) = 4

    C# has a function that would do this for you. This will allow you to plot small and large values on the same chart, while still seeing differences, because

    log10(5) = 0.700
    log10(8) = 0.903
    log10(75000) = 4.88

    Here is the log10 function in C#

    Code:
    [FONT=Courier New]public static double log10(double x)
    {
        if (x < 0)
        {
            return 0;
        }
        return Math.Log(x, 10.0);
    }[/FONT]
    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thanks, JessicaP.
      The filter looks the easiest option, but I'll probably give both a try and see what the results look like.

      Comment


        #4
        Just to report back, using Log10 in the indicator has worked well to keep the scale within reasonable limits.
        Code:
        myDataSeriesBear.Set(Math.Log10(bearVolPerTick / bullVolPerTick)/Period);
        myDataSeriesBull.Set(Math.Log10(bullVolPerTick / bearVolPerTick)/Period);
        Thanks.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Brevo, Today, 01:45 AM
        0 responses
        6 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 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
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        6 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X