Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Paint bars after candle cross EMA

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

    Paint bars after candle cross EMA

    I'm trying to develop an indicator that paint the bar in yellow color when it crosses EMA 10. If the candle is up, paint it in hollow. if the candle is down, paint it in solid yellow color.
    Could anyone give me some help?

    #2
    Hello ESHunter,

    Thank you for your post.

    To detect a crossover, you can use CrossAbove() and CrossBelow().





    Use BarBrushes to paint the color of a bar.



    Please let us know if you have nay further questions.

    Comment


      #3
      Thanks for you reply. I still not sure how to build an indicator from scratch. So, I found this indicator and made some modification
      10/2/2011 Edit entry. Error in download file. Corrected now. V2. Added the option to also paint the wicks on candlesticks based on a second SMA (default is 50 periods). This indicator will color the price bar red when price closes below the SMA and green when price close above the SMA (default period is 20) […]

      AddPlot(Brushes.Transparent, "SMAvg");

      Also,
      protected override void OnBarUpdate()
      {
      //Add your custom indicator logic here.

      // Use this method for calculating your indicator values. Assign a value to each
      // plot below by replacing 'Close[0]' with your own formula.
      double ttt = EMA(Close, sMA)[0];
      SMAvg[0] = (ttt);

      if (CrossBelow(Close, ttt, 1))
      {
      // Paint solid yellow
      CandleOutlineBrush = Brushes.LimeGreen;
      BarBrush = Brushes.LimeGreen;
      }
      // Check if price crosses up the EMA8
      else if (CrossAbove(Close, ttt, 1))
      {
      // Paint hollow yellow (outline yellow, but no fill)
      CandleOutlineBrush = Brushes.Yellow;
      BarBrush = Brushes.Transparent;​

      Now, I'm not sure if it's EMA or SMA. In addition, I was wondering how to make the color selection in the indicator importing phase.like, select the color of the bull candle that crosses up EMA8. Select the color of the bear candle that crosses down EMA 8

      Comment


        #4
        Based on the code you posted it looks like this is using the EMA calculation in the crossover check.

        I'm not sure what you mean by "make color selection in indicator importing phase"? Can you please elaborate, what do you mean by importing phase?

        Comment


          #5
          Sorry, it was my bad. I meant when I choose the indicator from the indicator list, I'd like to have the option to choose the color of the bull and bear candles

          Comment


            #6
            Hello ESHunter,

            Please see this Help Guide page on creating user defined color inputs.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X