A good place to start would be using the inbuilt Wizard to create a new Indicator.
Ballenoz did you take a look at the indicator? Its 99% complete.
You created the Objects in init, but didn't set the text in the start body. This means that your main code would calculate values but do nothing with them.
Also there was no code for the function myPoint()
You were using "Line1" as an object name when it didn't exist
I've made some changes to the code, maybe it will help you out and set you on the path to getting it to do exactly what you want.
I think that you still have some work to do
//+------------------------------------------------------------------+ //| ATR Comments.mq4 | //| by Threshold | //+------------------------------------------------------------------+ #property indicator_chart_window extern color font_color = Black; extern int font_size = 10; extern string font_face = "Arial"; extern int corner = 3; //0 - for top-left corner, 1 - top-right, 2 - bottom-left, 3 - bottom-right extern int OffsetHorizontal = 5; extern int OffsetVertical = 20; double myPoint; double SetPoint(); //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- int i=0; int R1=0,R10=0,R14=0,R21=0; R1 = (iHigh(NULL,PERIOD_D1,0)-iLow(NULL,PERIOD_D1,0))/myPoint; for(i=1;i<=10;i++) R10 = R10 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/myPoint; for(i=1;i<=14;i++) R14 = R14 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/myPoint; for(i=1;i<=21;i++) R21 = R21 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/myPoint; R10 = R10/10; R14 = R14/14; R21 = R21/21; ObjectSetText ("Text1","Current Day Range: " + R1 + "\n",font_size, font_face, font_color); ObjectSetText ("Text2","Current Day Range: " + R10 + "\n",font_size, font_face, font_color); ObjectSetText ("Text3","Current Day Range: " + R14 + "\n",font_size, font_face, font_color); ObjectSetText ("Text4","Current Day Range: " + R21 + "\n",font_size, font_face, font_color); return(0); } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init(){ if(Digits==5 || Digits==3) myPoint = Point*10; else myPoint = Point; ObjectCreate("text1", OBJ_LABEL, 0, 0, 0); ObjectSet("text1", OBJPROP_CORNER, corner); ObjectSet("text1", OBJPROP_YDISTANCE, OffsetVertical + 0 ); ObjectSet("text1", OBJPROP_XDISTANCE, OffsetHorizontal); ObjectCreate("text2", OBJ_LABEL, 0, 0, 0); ObjectSet("text2", OBJPROP_CORNER, corner); ObjectSet("text2", OBJPROP_YDISTANCE, OffsetVertical + 16 ); ObjectSet("text2", OBJPROP_XDISTANCE, OffsetHorizontal); ObjectCreate("text3", OBJ_LABEL, 0, 0, 0); ObjectSet("text3", OBJPROP_CORNER, corner); ObjectSet("text3", OBJPROP_YDISTANCE, OffsetVertical + 32 ); ObjectSet("text3", OBJPROP_XDISTANCE, OffsetHorizontal); ObjectCreate("text4", OBJ_LABEL, 0, 0, 0); ObjectSet("text4", OBJPROP_CORNER, corner); ObjectSet("text4", OBJPROP_YDISTANCE, OffsetVertical + 48 ); ObjectSet("text4", OBJPROP_XDISTANCE, OffsetHorizontal); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit(){ ObjectDelete("text1"); ObjectDelete("text2"); ObjectDelete("text3"); ObjectDelete("text4"); return(0); } //+------------------------------------------------------------------+
Thanks
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The bottom right corner.
I made my best attempt at it and have been tinkering with it for quite a while without much luck. Got it narrowed down to only 5 errors.
Anyone want to point out the corrections?