Adding Color to an indicator - page 3

 
mrchuckw:


Here's the way your ea looks after I have played with it. Can you tell me how to put the squared in a straight line. ?

Thanks

Just set the values for these variables to 0 . . .

if(Down.5.0) AshiRed[shift] = 0 ;
if(Up.5.0) AshiWhite[shift] = 0 ;
 
OK... I did that, now nothing shows up. I've tried putting in a number... like 1.43851 (current price) and it puts it in a straight line, but only for the start, then it starts jumping around again. And I can't figure out how to get the second line in there.... any ideas
 

this fractal indi might help.

 
mrchuckw:
OK... I did that, now nothing shows up. I've tried putting in a number... like 1.43851 (current price) and it puts it in a straight line, but only for the start, then it starts jumping around again. And I can't figure out how to get the second line in there.... any ideas
The problem is that the separate window auto scales for the data that is currently shown. I'm not sure of the best way to fix this . . . . I know what will work, create 2 new buffers for squares with no colour, set their values for bar 0 and bar 1 to 1 and -1 respectively . . then set the values for your red and white square buffers to 0 . . .
 
19730719:

something like this

int    iSquare=110;
double dGap=10*Point
int init()
  1. missing semicolon after point.
  2. Global variables can only be initialized with constants. Need to initialize inside init()
  3. EAs and Indicators must adjust 4/5 digit brokers. 10*Point is 10 pips on a 4 digit broker and 1 pip on a 5 - code breaks.
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

  4. I don't know why you'd want a square when you could use two different symbols like 225/226, 241/241, 67/68, 71/72
  5.     if ( counted_bars > 0 ) {counted_bars--;          // Last bar will be recounted
        }    
        int limit = Bars - counted_bars;
        for (int shift = limit; shift >=0 ; shift--)      // Paint bars going from left to right . . 
    
    The limit is Bars - 1 - counted_bars, i.e. first time counted==0 you loop from Bars - 1..zero. The decrement is unnecessary.
 
RaptorUK:
The problem is that the separate window auto scales for the data that is currently shown. I'm not sure of the best way to fix this . . . . I know what will work, create 2 new buffers for squares with no colour, set their values for bar 0 and bar 1 to 1 and -1 respectively . . then set the values for your red and white square buffers to 0 . . .

I'm still reading up on buffers. totally new to me, so I'm dragging my feet a bit.

What I have so far (indicator is separate window) is starting to work, but I can't get past this block.

I want the color of the 5 min chart in a small square on a straight line... in a separate indicator window.

I can't get white and red to show up on the same line. Then, I want to move on to the 15 min chart color on the next line.

I"m at a mental block or something.

Any ideas..? besides the indicator buffer... which I need to learn someday.

Files:
ashi-2.mq4  3 kb
 
mrchuckw:

I'm still reading up on buffers. totally new to me, so I'm dragging my feet a bit.


This will help: https://book.mql4.com/samples/icustom
 
mrchuckw:

I"m at a mental block or something.

Any ideas..? besides the indicator buffer... which I need to learn someday.

Try this . . but please use it to learn, I have commented what I have added or changed, print it out, print out your version 2 and compare them side by side . . . study, understand, practice it's the only way to learn . . .

If you have any questions on why I did what I did please ask and I'll explain.

Files:
ashi-2.1.mq4  4 kb
 
You will need to set the colour for the 5th and 6th buffers to the background colour of your chart.
 
RaptorUK:

Try this . . but please use it to learn, I have commented what I have added or changed, print it out, print out your version 2 and compare them side by side . . . study, understand, practice it's the only way to learn . . .

If you have any questions on why I did what I did please ask and I'll explain.

This is Perfect. Thank you so much. It is doing exactly what I wanted. I have played with it, moved the lines around a bit, and added more chart time frames.

The only thing.... I can't get more than 4 lines. Took out the Top and Bottom you added, and I have the 5 min, 15 min, 30 min and 60 min. Would like to add the 240 (4 hour) but not that critical.

I liked the top and bottom lines... it centered the other much better, but I sacrificed them to get the other lines.

Also... how do you get the indicator to repaint like it was being loaded for the first time... the 5 min and up move along with the 1 min. (the chart I have the indicator on), so it looks a bit skewed..

For instance... if the 1 min is going down, the chart will show a red bar, for each down bar. After several red bars, the 5 min will show several red bars too, but it may only be down 1 bar... Kind of make you think the 5 min has been going down longer than it has.

But not that important, because for entry points I only look at the current bar.

Again, thank so much!!!!!

Reason: