Positioning Objects

 

Im creating a text label object but cant seem to get the placement where I want it ie. just above the actual bar that is the signal. But regardless of the bars location, the Text always shows up in the same location (midupper left) What am I doing wrong?

I have a signal bar who's postion is p, passed to the following routine:


void SignalObject(int p)
{ if(ObjectCreate("Signal", OBJ_LABEL, 0, Time[p], High[p]))
{ObjectSetText("Signal", "Buy!", 10, "Times New Roman", Gold);}
else {Print("error: cant create label_object! code #",GetLastError());}
return(0);
}

 
Hello,
That's sounds ok. What is the value of p : it must be 0 if you want your object on the actual bar.
 
Jacques366:

Its one bar previous to the current bar (Bars-1). I also tried using [0] but it doesnt work, same reult. Maybe you can explain to me how the positioning scheme is supposed to work. The Docs on the CreateObject or MoveObject fucntions dont explain where to get the values for Time and Price, so I used the code shown thinking it might/should work.

 

If you want your object on the current bar - 1, p should = 1.

Nothing to add to the explaination given in the ObjectCreate function, it works as it is said.

 
Jacques366:

If you want your object on the current bar - 1, p should = 1.

Nothing to add to the explaination given in the ObjectCreate function, it works as it is said.

well, i tried again using [0] and also printed the values of Time[0] and High[0]. i get a long string of numbers for time, 123...... and the High value is not even a legit value for the current bar. So somethings NOT correct. The Docs suck. Just tell you to use a time and price, with no explanation how to derive these values. So as you can see im left guessing.

The old CIAK principle. Clear If Already Known.


Anyone want to throw some example code my way thanks. All it needs to do is place some text lable just above the current bar.

 
hkjonus wrote >>

well, i tried again using [0] and also printed the values of Time[0] and High[0]. i get a long string of numbers for time, 123...... and the High value is not even a legit value for the current bar. So somethings NOT correct. The Docs suck. Just tell you to use a time and price, with no explanation how to derive these values. So as you can see im left guessing.

The old CIAK principle. Clear If Already Known.

Anyone want to throw some example code my way thanks. All it needs to do is place some text lable just above the current bar.

OK, I tried your code and apparently that the name 'Signal' that is causing problem. It will work with 'Sig' instead of 'Signal' for example . Don't ask me why, it must be a reserved word.

This lines work:

ObjectCreate("Sig",OBJ_TEXT,0,Time[0],High[0]);
ObjectSetText("Sig", "Buy!", 10, "Times New Roman", Gold);

You may find it is not really above the bar, search on the forum for the solution I do not have it yet, may be someone else can help there.

Reason: