Drawing Objects Question

 

With the following code, I can place a dot at the bottom of a candle, for a specific value. I would like to place a second dot below the first, for a second value. Can anyone show me how to accomplish this? I would also like to know how to add spacing between the first dot and the candle, so that the dot is not touching the candle.

Thanks!

ObjectCreate(StringConcatenate("MidASymblA",TimeCurrent()), OBJ_ARROW, 0, Time[1],vLa+_Point);

ObjectSet(StringConcatenate("MidASymblA",TimeCurrent()), OBJPROP_ARROWCODE, 108);

ObjectSet(StringConcatenate("MidASymblA",TimeCurrent()), OBJPROP_COLOR, White);

ObjectSet(StringConcatenate("MidASymblA",TimeCurrent()), OBJPROP_ANCHOR, ANCHOR_TOP);

ObjectCreate(StringConcatenate("MidASymblAs",TimeCurrent()), OBJ_ARROW, 0, Time[1],NSpread+_Point);

ObjectSet(StringConcatenate("MidASymblAs",TimeCurrent()), OBJPROP_ARROWCODE, 108);

ObjectSet(StringConcatenate("MidASymblAs",TimeCurrent()), OBJPROP_COLOR, White);

ObjectSet(StringConcatenate("MidASymblAs",TimeCurrent()), OBJPROP_ANCHOR, ANCHOR_TOP);

 

YellowBeard:

The first step is to make your code into a function like this example, courtesy of MLaden. The function manageArrows uses a preset variable Trend to print either up or down arrows. You could remove the Trend parameter and instead add formal parameters for the Type, first dot or second dot, add a color parameter to differentiate between the two types of your dots. You would use Type to adjust the value of the dist variable, dist*1.5 for the vertical offset of your second dot. So your function head may look something like this:

void manageArrow(int i, int Type, color Color)

Then you would place one or two calls in your code replacing the object calls you showed which will now be contained in your new function.

manageArrow(i,0.clrRed);

manageArrow(i,1,clrLime);

To completely generalize your new function you can review my Create_Label function that is included at the end. This uses a variable IndicatorName that must be set as the final lines in the Init() function as

IndicatorName = "SomeName";

IndicatorShortName(IndicatorName);

The trick to using my Create_Label function is to use the font Webdings and to specify the text by its character code chr(233) in the call

Good Luck

Tzuman

string ArrowsIdentifier = "GB Macd Arrows

extern int ArrowUpCode = 233;

extern int ArrowDownCode = 234;

extern color ArrowUpColor = Lime;

extern color ArrowDownColor = Crimson;

extern int ArrowWidth = 4;

void manageArrow(int i, int Trend)

{

if(Trend == 0 || !ShowArrows) return;

ObjectDelete(ArrowsIdentifier+Time);

double dist = iATR(NULL,0,20,i)/4.;

string name = ArrowsIdentifier+Time;

if (Trend == 1) {

ObjectCreate(name,OBJ_ARROW,0, Time,Low-dist);

ObjectSet(name,OBJPROP_ARROWCODE,ArrowUpCode);

ObjectSet(name,OBJPROP_COLOR,ArrowUpColor);

ObjectSet(name,OBJPROP_WIDTH,ArrowWidth);

ObjectSet(name,OBJPROP_BACK,true);

}

else {

ObjectCreate(name,OBJ_ARROW,0, Time,High+dist*2.0 );

ObjectSet(name,OBJPROP_ARROWCODE,ArrowDownCode);

ObjectSet(name,OBJPROP_COLOR,ArrowDownColor);

ObjectSet(name,OBJPROP_WIDTH,ArrowWidth);

ObjectSet(name,OBJPROP_BACK,true);

}

}

void Create_Label(string buffer, int x, int y, string Text, int fontSize, string Font, color cColor, int corner=0 ) {

if(!ShowArrows && !ShowText) return;

if (ObjectFind(buffer) == -1) {

Window = WindowFind(IndicatorName);

if(Window < 1 ) Window=1;

ObjectCreate(buffer, OBJ_LABEL, Window, 0, 0 );

}

ObjectSet(buffer, OBJPROP_CORNER, corner);

ObjectSet(buffer, OBJPROP_XDISTANCE,x+MoveHorizontal);

ObjectSet(buffer, OBJPROP_YDISTANCE,y+MoveVertical);

ObjectSetText(buffer, Text, fontSize, Font, cColor);

}