Draw Line on Array & MathPow

To add comments, please log in or register
Panjianom Adi Pratomo
532
Panjianom Adi Pratomo  

Hi All,

Can anybody help me please?
I have been trying to draw lines in an array that is in a sequence of square the array by using MathPow.
This code only drawn 1 horizontal line only and without drawn fibonacci line:



This how far have gone:

#property strict
#property show_inputs
#property indicator_chart_window
#define  NL    "\n"


extern color LineColor=Green;
extern ENUM_LINE_STYLE LineStyle=STYLE_SOLID;
extern int LineWidth=1;

int init()
{
 
  //----
  return(0);
}

int deinit()
{
  ObjectsDeleteAll(0,EMPTY,EMPTY);
  Comment ("");
  //----
  return(0);
}

int start()
{
  double ArraySquare[];
  int Limit=40;
  int priceindex;
  int y=2;

  for(int i=1; i<Limit; i++)
  {
    ArrayResize(ArraySquare, Limit, 0);
    ArraySquare[i] = MathPow(i, y);
    priceindex = ArraySquare[i];

    DrawLine(priceindex);
    DrawFibo(priceindex);

    Comment(i, " ^ ", y, " = ", priceindex);
    Print(i, " ^ ",  y, " = ", priceindex);
  }

    return(0);
}

void DrawLine(double priceindex)
{
  ObjectDelete("Line");
  ObjectCreate("Line", OBJ_HLINE, 0, 0, priceindex);
  ObjectSet("Line", OBJPROP_STYLE, LineStyle);
  ObjectSet("Line", OBJPROP_COLOR, LineColor);
  ObjectSet("Line", OBJPROP_WIDTH, LineWidth);
}

void DrawFibo(double priceindex)
{
  ObjectCreate("FiboLine",OBJ_FIBO,0,0,priceindex-1,0,priceindex);
  ObjectSet("FiboLine",OBJPROP_RAY,true);
  ObjectSet("FiboLine",OBJPROP_COLOR,Gray);
  ObjectSet("FiboLine",OBJPROP_LEVELCOLOR,LineColor);
  ObjectSet("FiboLine",OBJPROP_FIBOLEVELS,3);
  ObjectSet("FiboLine",OBJPROP_LEVELSTYLE,LineStyle);
  ObjectSet("FiboLine",OBJPROP_LEVELWIDTH,LineWidth);
  ObjectSet("FiboLine",OBJPROP_FIRSTLEVEL,0.0);
  ObjectSet("FiboLine",OBJPROP_FIRSTLEVEL+1,0.5);
  ObjectSet("FiboLine",OBJPROP_FIRSTLEVEL+2,1.0);
  ObjectSetFiboDescription("FiboLine",0,"0/2 @%$");
  ObjectSetFiboDescription("FiboLine",1,"1/2 @%$");
  ObjectSetFiboDescription("FiboLine",2,"2/2 @%$");
}


Any suggestions would be welcome. Thanks in advanced.

To add comments, please log in or register