This code doesn't draw anything? - page 2

 
robofx.org:

If you use the code as an indicator the lines will move to the right automatically.

Sorry, it needs to be a script as I am going to incorporate it as part of a buy script so it draws the lines automatically (target lines).

I added ray = true but it now draws the line across the whole page all the way to the left where it should really be going the other way :)

 
SanMiguel:

Sorry, it needs to be a script as I am going to incorporate it as part of a buy script so it draws the lines automatically (target lines).

I added ray = true but it now draws the line across the whole page all the way to the left where it should really be going the other way :)

If you write a script there's no need to run the whole for cycle. It's a waste of time. You may use this:

//testing variable

double inputlevel = 1.4;


int i;

double level1=inputlevel+(20*Point*10); //+20pips

double level2=inputlevel+(30*Point*10); //+30pips

double level3=inputlevel+(40*Point*10); //+40pips

double level4=inputlevel+(80*Point*10); //+80pips


datetime dtStart = iTime(NULL,PERIOD_M15,4);

datetime dtEnd = iTime(NULL,PERIOD_M15,0);


ObjectDelete("Line1");

ObjectCreate("Line1",OBJ_TREND,0,dtStart,level1, dtEnd, level1);

ObjectSet("Line1",OBJPROP_COLOR,Red);

ObjectSet("Line1",OBJPROP_STYLE,STYLE_SOLID);

ObjectSet("Line1", OBJPROP_RAY, false);

ObjectSet("Line1",OBJPROP_WIDTH,1);

.............................................................


But I'm not sure what you're trying to do.. and why you want the lines to move right. If it is a script it executes, draws the lines, open trades and exits. And that's all.


 
robofx.org:

If you write a script there's no need to run the whole for cycle. It's a waste of time. You may use this:

//testing variable

double inputlevel = 1.4;


int i;

double level1=inputlevel+(20*Point*10); //+20pips

double level2=inputlevel+(30*Point*10); //+30pips

double level3=inputlevel+(40*Point*10); //+40pips

double level4=inputlevel+(80*Point*10); //+80pips


datetime dtStart = iTime(NULL,PERIOD_M15,4);

datetime dtEnd = iTime(NULL,PERIOD_M15,0);


ObjectDelete("Line1");

ObjectCreate("Line1",OBJ_TREND,0,dtStart,level1, dtEnd, level1);

ObjectSet("Line1",OBJPROP_COLOR,Red);

ObjectSet("Line1",OBJPROP_STYLE,STYLE_SOLID);

ObjectSet("Line1", OBJPROP_RAY, false);

ObjectSet("Line1",OBJPROP_WIDTH,1);

.............................................................


But I'm not sure what you're trying to do.. and why you want the lines to move right. If it is a script it executes, draws the lines, open trades and exits. And that's all.


I had to swap the dtEnd and dtStart round so it would draw Ray lines to the right.

I think I need to leave the loop in or it doesn't know where to start the Bars from.

Thanks for your help.


int start()
  {
double inputlevel = Bid;
//int    counted_bars=IndicatorCounted();
int i;
double level1=inputlevel-(20*Point*10); //+20pips
double level2=inputlevel-(30*Point*10); //+30pips
double level3=inputlevel-(40*Point*10); //+40pips
double level4=inputlevel-(80*Point*10); //+80pips

for(i=Bars;i>=+4;i--)
{
    datetime dtStart = iTime(NULL,PERIOD_M15,i-4);
    datetime dtEnd = iTime(NULL,PERIOD_M15,i);
    
    ObjectDelete("Line1");
    ObjectCreate("Line1",OBJ_TREND,0, dtEnd, level1, dtStart, level1); 
    ObjectSet("Line1",OBJPROP_COLOR,LightGreen);
    ObjectSet("Line1",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSet("Line1", OBJPROP_RAY, true);
    ObjectSet("Line1",OBJPROP_WIDTH,2);
 
    ObjectDelete("Line2");
    ObjectCreate("Line2",OBJ_TREND,0, dtEnd, level2, dtStart, level2);
    ObjectSet("Line2",OBJPROP_COLOR,LightGreen);
    ObjectSet("Line2",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSet("Line2", OBJPROP_RAY, true);
    ObjectSet("Line2",OBJPROP_WIDTH,2);

    ObjectDelete("Line3");
    ObjectCreate("Line3",OBJ_TREND,0, dtEnd, level3, dtStart, level3);
    ObjectSet("Line3",OBJPROP_COLOR,LightGreen);
    ObjectSet("Line3",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSet("Line3", OBJPROP_RAY, true);
    ObjectSet("Line3",OBJPROP_WIDTH,2);

    ObjectDelete("Line4");
    ObjectCreate("Line4",OBJ_TREND,0, dtEnd, level4, dtStart, level4);
    ObjectSet("Line4",OBJPROP_COLOR,LightGreen);
    ObjectSet("Line4",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSet("Line4", OBJPROP_RAY, true);
    ObjectSet("Line4",OBJPROP_WIDTH,2);
}
   return(0);
  }
 
SanMiguel:

I had to swap the dtEnd and dtStart round so it would draw Ray lines to the right.

I think I need to leave the loop in or it doesn't know where to start the Bars from.

Thanks for your help.


You're welcome. Good luck!

 

Please let me ask again,


what's the point of the (...still buggy...) loop? What does it do besides the heating CPU and delaying start() execution?

I'm really curious.

 

I agree but if you don't add the loop, it draws a line across the entire screen. Must be something to do with finding the bars.

?

Reason: