i created a function that will create a fibo the way i want it to, however, it doesnt change the color?
attached is a "test" indicator to demo the problem.
here is the calling code (i used the daily GBP/USD for demo):
here is the color change code in the function below that doesnt work:
here is the function:
attached is a "test" indicator to demo the problem.
here is the calling code (i used the daily GBP/USD for demo):
Inserted Code
string objName = "fib" + Time[0];
bool bResult = createFib(objName, Time[0], 2.0300, 2.0500, DeepSkyBlue, false);
if(bResult == false)
{
Print("error creating fib: error code: ", GetLastError());
} here is the color change code in the function below that doesnt work:
Inserted Code
//set the color of the fib
ObjectSet(name, OBJPROP_COLOR, fibColor); here is the function:
Inserted Code
//+------------------------------------------------------------------+
//| function setFib |
//+------------------------------------------------------------------+
bool createFib(string name, datetime date, double price1, double price2, color fibColor, bool bRayFlag)
{
bool ret = false;
bool result = false;
result = ObjectCreate(name, OBJ_FIBO, 0, date, price1, date, price2);
Print("createFib: result = ", result);
if(result == true)
{
Print("fib ", name, " created succesfully");
//set the number of fib levels
ObjectSet(name, OBJPROP_FIBOLEVELS, 13);
//set the value of each fib level
ObjectSet(name, OBJPROP_FIRSTLEVEL+1, 0.000);
ObjectSet(name, OBJPROP_FIRSTLEVEL+2, 0.236);
ObjectSet(name, OBJPROP_FIRSTLEVEL+3, 0.382);
ObjectSet(name, OBJPROP_FIRSTLEVEL+4, 0.500);
ObjectSet(name, OBJPROP_FIRSTLEVEL+5, 0.618);
ObjectSet(name, OBJPROP_FIRSTLEVEL+6, 0.768);
ObjectSet(name, OBJPROP_FIRSTLEVEL+7, 0.860);
ObjectSet(name, OBJPROP_FIRSTLEVEL+8, 1.000);
ObjectSet(name, OBJPROP_FIRSTLEVEL+9, -0.180);
ObjectSet(name, OBJPROP_FIRSTLEVEL+10, -0.270);
ObjectSet(name, OBJPROP_FIRSTLEVEL+11, -0.618);
ObjectSet(name, OBJPROP_FIRSTLEVEL+12, -1.618);
//set the description of each fib level
ObjectSetFiboDescription(name, 1, "B");
ObjectSetFiboDescription(name, 2, "23.6");
ObjectSetFiboDescription(name, 3, "38.2");
ObjectSetFiboDescription(name, 4, "50.0");
ObjectSetFiboDescription(name, 5, "61.8");
ObjectSetFiboDescription(name, 6, "76.8");
ObjectSetFiboDescription(name, 7, "86.0");
ObjectSetFiboDescription(name, 8, "A");
ObjectSetFiboDescription(name, 9, "118.0");
ObjectSetFiboDescription(name, 10, "127.0");
ObjectSetFiboDescription(name, 11, "161.8");
ObjectSetFiboDescription(name, 12, "261.8");
//set the ray flag
ret = ObjectSet(name, OBJPROP_RAY, bRayFlag);
Print("ray set: ", ret);
if(ret == false)
{ Print("error: ", GetLastError());}
//set the color of the fib
ret = ObjectSet(name, OBJPROP_COLOR, fibColor);
Print("color set: ", ret, ": color = ", fibColor);
if(ret == false)
{ Print("error: ", GetLastError());}
color currentColor = ObjectGet("name", OBJPROP_COLOR);
Print("currentColor = ", currentColor);
}//end if the fib object is created with no errors
ret = result;
return (ret);
}//end function setFib Attached File(s)