Windowredraw problem

 

I include the code for the indicator that I did. The problem is that the lines and text show correctly at the start. how ever I would like the text to remain where it starts and not move as the bars progress

can someone help me I know I am missing something small but I can figure this out

Thank you

#property indicator_chart_window

extern color PH_Color = Aqua;


int init()
{

return(0);
}

int deinit()
{
ObjectsDeleteAll(0, OBJ_HLINE);
ObjectsDeleteAll(0, OBJ_TEXT);
ObjectsDeleteAll(0, OBJ_LABEL);

return( 0 );

}

int start()
{

int hnd;
double val1;
string val10;
int marg;

string File_Name = Symbol() + ".CSV";

hnd=FileOpen(File_Name, FILE_CSV|FILE_READ,";");
if(hnd>0)

{

val1 = FileReadNumber(hnd);

val10 = FileReadString(hnd);

}

FileClose(hnd);

int p = Period();
datetime T1 = TimeCurrent();
datetime T2 = Time[0];
Print("T1 = " + T1);Print("T2 = " + T2);

ObjectCreate( "Previous Day High Level", OBJ_HLINE, 0, NULL, val1 );
ObjectSet( "Previous Day High Level", OBJPROP_COLOR, PH_Color );
ObjectCreate("Previous Day High", OBJ_TEXT, 0,T1 + 10 *p*60, val1);
ObjectSetText("Previous Day High", " PH ", 12, "Times New Roman", PH_Color);


if(T1-T2 == p) {
WindowRedraw();
}

return(0);

}

 
richbois wrote >>




if(T1-T2 == p) {
WindowRedraw();
}

T1 and T2 are in seconds; p is in minutes

 
ronaldosim wrote >>

T1 and T2 are in seconds; p is in minutes

I see what you mean however when I watch the print values on a 1 minute chart as soon as the minute expires T2 refreshes and updates to T1 but not the Label doesnt. The label stays relative to the original bar when the indicator was launched. what I am trying to acheive is that the label stay relative to the last bar

 
richbois wrote >>

I see what you mean however when I watch the print values on a 1 minute chart as soon as the minute expires T2 refreshes and updates to T1 but not the Label doesnt. The label stays relative to the original bar when the indicator was launched. what I am trying to acheive is that the label stay relative to the last bar

once you have created an object (the label in this case), u don't have to create anymore, use ObjectMove;

code wld be something like this

if(ObjectFind(labelname) != 0)
{
ObjectCreate(labelname, OBJ_TEXT, 0, timescale, lvl);
ObjectSetText(labelname, labeltext, labelfontsize, labelfont, labelcolor);
}
else
{
ObjectMove(labelname, 0, timescale, lvl);
ObjectSetText(labelname, labeltext, labelfontsize, labelfont, labelcolor);
}

 
ronaldosim wrote >>

once you have created an object (the label in this case), u don't have to create anymore, use ObjectMove;

code wld be something like this

if(ObjectFind(labelname) != 0)
{
ObjectCreate(labelname, OBJ_TEXT, 0, timescale, lvl);
ObjectSetText(labelname, labeltext, labelfontsize, labelfont, labelcolor);
}
else
{
ObjectMove(labelname, 0, timescale, lvl);
ObjectSetText(labelname, labeltext, labelfontsize, labelfont, labelcolor);
}

You Da Man

Thank you very much that worked great

Reason: