Adding Color to an indicator - page 2

 

I still haven't figured out the indicator buffers yet,

but the following code does what I want, display current and past bar Heiken Ashi color.

What it doesn't do is put it in a separate window, and display ONLY under the current bar.

is that possible? Or do I still need to figure out the indicator buffer?

You are dealing with a very green newbie... thanks for the patience.

int start()

{

ObjectsDeleteAll();

// clear the chart before drawing

// 5 min current

double open.5.0 =iCustom(NULL,1,"Heiken Ashi",0,2,0); //Previous Open

double close.5.0 =iCustom(NULL,1,"Heiken Ashi",0,3,0); //Previous Close


bool Up.5.0 = (close.5.0>open.5.0);

bool Down.5.0 = (close.5.0<open.5.0);

// 5 min past

double open.5.1 =iCustom(NULL,1,"Heiken Ashi",0,2,1); //Previous Open

double close.5.1 =iCustom(NULL,1,"Heiken Ashi",0,3,1); //Previous Close

bool Up.5.1 = (close.5.1>open.5.1);

bool Down.5.1 = (close.5.1<open.5.1);


ObjectCreate("square1",OBJ_RECTANGLE, 0, TimeCurrent(), Ask-0.001, 0, Bid-0.001);

if(Down.5.0 == 1) ObjectSet("square1",OBJPROP_COLOR,Red);


ObjectCreate("square1",OBJ_RECTANGLE, 0, TimeCurrent(), Ask-0.001, 0, Bid-0.001);

if(Down.5.0 == 0) ObjectSet("square1",OBJPROP_COLOR,White);


ObjectCreate("square2",OBJ_RECTANGLE, 0, TimeCurrent(), Ask-0.0015, 0, Bid-0.0015);

if(Down.5.1 == 1) ObjectSet("square2",OBJPROP_COLOR,Red);


ObjectCreate("square2",OBJ_RECTANGLE, 0, TimeCurrent(), Ask-0.0015, 0, Bid-0.0015);

if(Down.5.1 == 0) ObjectSet("square2",OBJPROP_COLOR,White);


return(0);

}

 

Please use this to post code . . . it makes it easier to read.

 
mrchuckw:

I still haven't figured out the indicator buffers yet,

but the following code does what I want, display current and past bar Heiken Ashi color.

What it doesn't do is put it in a separate window, and display ONLY under the current bar.

is that possible? Or do I still need to figure out the indicator buffer?

I think you would need to draw an indicator on the separate window to get the window in the first place so you could add the objects to it . .
 

something like this

double adUpBuffer[],
       adDnBuffer[];
//---- indicator colors
color  cDirection[2]={LimeGreen,FireBrick};
string sDirection[2]={"up", "down"};
int    iSquare=110;
double dGap=10*Point
//+------------------------------------------------------------------+
//   Custom indicator initialization function                        |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   IndicatorBuffers(2);
   for(int i=0;i<2;i++){
   SetIndexStyle(i,DRAW_ARROW,clrDirection[i]);
   SetIndexArrow(i,iSquare);
   SetIndexDrawBegin(i,12);
   SetIndexLabel(i,sDirection[i]);}
//---- 2 indicator buffers mapping
   SetIndexBuffer(0,adUpBuffer);
   SetIndexBuffer(1,adDnBuffer);
//---- initialization done
   return(0);
  }


      if(Up.5.0)
           adUpBuffer[i]=Low[i]-dGap;
      else adDnBuffer[i]=NULL;
      if(Dn.5.0)
           adDnBuffer[i]=High[i]+dGap;}
      else adDnBuffer[i]=NULL;} 
 

I'm not good with Indicators . . . take a look at this see if it gives you what you need . . .

Files:
ashi1.mq4  3 kb
 

ok..I'm working on it... but you assume I know MUCH more that I do.

Attached is my whole indicator program so far. How would I put your code into it? Or do I create a whole new program?

I tried sticking it in the best I could, but I can't compile. It doesn't like the double dGap=10*Point even after I put a ; after it.

And there was a ton of other compiling errors. I guess I'm just dense enough to not know what to do now.

Files:
objects2.mq4  3 kb
 
mrchuckw:

ok..I'm working on it... but you assume I know MUCH more that I do.

Attached is my whole indicator program so far. How would I put your code into it? Or do I create a whole new program?

I tried sticking it in the best I could, but I can't compile. It doesn't like the double dGap=10*Point even after I put a ; after it.

And there was a ton of other compiling errors. I guess I'm just dense enough to not know what to do now.

Just download my code, copy it to your MT4 directory structure in Indicators. stop and restart MT4 then add the Indicator to a chart . . if you are using Indicator buffers you don't use objects.
 

where do I download your code?

see how dense I am?

 
mrchuckw:

where do I download your code?

see how dense I am?

It's attached to my post, a couple of posts above . . . ashi1.mq4
 

this is nearly perfect. I have been playing with it, and having a ball.

I think I might have murdered it, but I now have it putting the squares in a separate window.

That part is working perfectly. Now... I can't figure out how to have all the squared in a perfect line.

Because, I want to put another line under that one. I think I can figure out how to do that... at least I will have fun trying.

the new line will be a larger time frame. And 3rd line would be yet another larger time frame.

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

ps... I've been playing with this for a while, and I can't figure out how to get a second and third line, and make them straight.

If you could help me with that I would appreciate it. 2nd file is my attempt at the second line.

Files:
ashi1_1.mq4  3 kb
ashi1-a.mq4  3 kb
Reason: