So this section should not be same date time:
time1 = iTime(NULL,0,1); time2 = time1;
it can be like :
time1 = iTime(NULL,0,1); time2 = iTime(NULL,0,10);Do as documentation example carefully.
So this section should not be same date time:
it can be like :
Do as documentation example carefully.So how do you put a fibonacci on a single candle? It has the same time for points 1 & 2?
Different price 1 & 2.
OK,So main issue is the levels,you should divide your levels by 100,then spend it to fibo value array ,like this:
void OnStart() { datetime time1,time2; double price1,price2; int chart_ID= 0; string name = "fibname"; double fib_values[13]={0.0,.236,.382,.500,.550,.618,.786,1.000,1.272,1.411,1.618,2.618,4.236}; time1 = iTime(NULL,0,1); time2 = iTime(NULL,0,2); price1 = iLow(NULL,0,1); price2 = iHigh(NULL,0,1); //--- Create Fibonacci Retracement by the given coordinates if(!ObjectCreate(chart_ID,name,OBJ_FIBO,0,time1,price1,time2,price2)) { Print(__FUNCTION__, ": failed to create \"Fibonacci Retracement\"! Error code = ",GetLastError()); return; } ObjectSetInteger(chart_ID,name,OBJPROP_FIBOLEVELS,13); for(int i=0;i<13;i++) { Print(fib_values[i]); //--- level value ObjectSetDouble(chart_ID,name,OBJPROP_FIRSTLEVEL+i,fib_values[i]); ObjectSetString(chart_ID,name,OBJPROP_LEVELTEXT,i,DoubleToString(100*fib_values[i],1)); } ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,Magenta); ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,STYLE_SOLID); ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,1); ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,False); return; }
If you are using it in an indicator the main event handler function should be OnCalculate() and also for EA should be OnTick(),
Regards.
OK,So main issue is the levels,you should divide your levels by 100,then spend it to fibo value array ,like this:
If you are using it in an indicator the main event handler function should be OnCalculate() and also for EA should be OnTick(),
Regards.
Thank you very much.
Thank you very much.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
HI guys,
I can display the default fib on charts no problem but if I want a custom set of levels I run into problems. I read the documentation here https://docs.mql4.com/constants/objectconstants/enum_object/obj_fibo which shows the code but doesn't actually use it in the example!
Can anybody offer any ideas as to where I have gone wrong please?