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

single line different tones of colors

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

    single line different tones of colors

    I am wondering whether is it possible coloring a plot or line by gradient colors.

    What i am trying to achive for example drawing a plot or line at the best bid and coloring that according the number of contracts offered that level.

    i was trying this but it doesnt seem to be working:

    Code:
    Add(new Plot(new Pen(linecolor1, 2), PlotStyle.Block, "Ask"));
    Add(new Plot(new Pen(linecolor2, 2), PlotStyle.Block, "Bid"));
    	
    ratio=Math.Min(1f,((float)Math.Abs(askTick))/(((float)FixedNumber)));
    linecolor1=Color.FromArgb((int)(255f*ratio),Color.Red);
    Plots[0].Pen.Color = linecolor1;		
    											
    ratio2=Math.Min(1f,((float)Math.Abs(bidTick))/(((float)FixedNumber)));
    linecolor2=Color.FromArgb((int)(255f*ratio2),Color.Green);
    Plots[1].Pen.Color = linecolor2;
    thanks in advance!
    Last edited by andre.adamov; 03-11-2014, 05:33 AM.

    #2
    Hi Andre, working with the allpha channel of FromArgb would be the right approach. As for an example would only be aware of http://www.ninjatrader.com/support/f...d=1&linkid=294

    I would suggest setting the colors via PlotColors in NT7 - http://www.ninjatrader.com/support/h...sub=PlotColors
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick answer.
      Firstly I couldn't use it but fortunately i found the solution in the comment section. I think it should be updated according to this:


      second, I was trying to change to colors with no luck by overwriting theese numbers:
      Color red = Color.FromArgb(255, 0, 0);
      Color green = Color.FromArgb(0, 255, 0);

      What should I do to change the colors?

      Comment


        #4
        Andre, thanks for the reply. What would your custom colors / ratios be printing for each bar, would they provide the dynamic change you seek? If your ratio would just be 1 for example it would be easily creating a static color only...
        BertrandNinjaTrader Customer Service

        Comment


          #5
          The ratio would change for each bar.
          It would be the depth of market at that level compared to a pre-defined fix number.

          ratio=Math.Min(1f,((float)Math.Abs(askTick))/(((float)FixedNumber)));

          in this case: ask limit orders / my reference level

          Comment


            #6
            I see thanks. Would definitely print that value out to doublecheck the calcs are hitting 'home' for you. Here's a quick test I just ran using PlotColors to push the colors to, I'm not seeing any issue with dynamically changing color generally this way -

            Code:
            ratio = Math.Min(1f,((float)Math.Abs(Volume[0]))/(((float)SMA(Volume, 10)[0])));
            linecolor1=Color.FromArgb((int)(255f * 0.75 * ratio),Color.Red);
            PlotColors[0][0] = linecolor1;		
            Plot0.Set(SMA(10)[0]);
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thank you Bertrand!
              You were right, the calculation was wrong.
              The coloring is fine now.

              The last thing is that i dont know how to acces n-th level of ask or bid.

              bidTick = GetCurrentBid();
              bidTickVolume = GetCurrentBidVolume();

              with this i can acces the price and depth of the best bid but I need for instance the 5th level.
              how can I get that?

              Comment


                #8
                Great. Correct those would give you the current bid /ask of the Level1 data only. For deeper levels you would need to check into the OnMarketDepth() - http://www.ninjatrader.com/support/h...=OnMarketDepth
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by TraderBCL, Today, 04:38 AM
                2 responses
                16 views
                0 likes
                Last Post TraderBCL  
                Started by martin70, 03-24-2023, 04:58 AM
                14 responses
                106 views
                0 likes
                Last Post martin70  
                Started by Radano, 06-10-2021, 01:40 AM
                19 responses
                609 views
                0 likes
                Last Post Radano
                by Radano
                 
                Started by KenneGaray, Today, 03:48 AM
                0 responses
                5 views
                0 likes
                Last Post KenneGaray  
                Started by thanajo, 05-04-2021, 02:11 AM
                4 responses
                471 views
                0 likes
                Last Post tradingnasdaqprueba  
                Working...
                X