Roddo: I have attached the both working Indicators so you can see what I have done.
| What we need to see is the code that doesn't work. |
WHRoeder:
Roddo: I have attached the both working Indicators so you can see what I have done. | What we need to see is the code that doesn't work. |
Hi WHRoeder,
Thanks for the reply.
the Indicators both work separately. It is when they are both on the chart at the same time is when neither work.
I actually had them in the same indicator to start with but they seemed to cancel each other out.
At the moment I am using just one button and ending the loop with a 5 and sending it back to 0 .
Thank you for your interest
Roddo
//+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //+------------------------------------------------------------------+ //| ZoomIN sparam | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| ZoomIN sparam | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| ZoomOUT sparam | //+------------------------------------------------------------------+ if(id==CHARTEVENT_OBJECT_CLICK) { if(sparam==Zout_Button) Zout_Toggle(); { if(ChartGetInteger(0,CHART_SCALE,0,result)) { if(result==5) { ChartSetInteger(0,CHART_SCALE,0,4);//Comment Print("Chart Scale = "+(string)result); } else if(result==4) { ChartSetInteger(0,CHART_SCALE,0,3); Print("Chart Scale = "+(string)result); } else if(result==3) { ChartSetInteger(0,CHART_SCALE,0,2); Print("Chart Scale = "+(string)result); } else if(result==2) { ChartSetInteger(0,CHART_SCALE,0,1); Print("Chart Scale = "+(string)result); } else if(result==1) { ChartSetInteger(0,CHART_SCALE,0,0); Print("Chart Scale = "+(string)result); } } } } } //+------------------------------------------------------------------+ //| ZoomOUT sparam | //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //+------------------------------------------------------------------+ //| ZoomIN sparam | //+------------------------------------------------------------------+ if(id==CHARTEVENT_OBJECT_CLICK) { if(sparam==Zin_Button) Zin_Toggle(); { if(ChartGetInteger(0,CHART_SCALE,0,result)) { if(result==0) { ChartSetInteger(0,CHART_SCALE,0,1);//Comment Print("Chart Scale = "+(string)result); } else if(result==1) { ChartSetInteger(0,CHART_SCALE,0,2); Print("Chart Scale = "+(string)result); } else if(result==2) { ChartSetInteger(0,CHART_SCALE,0,3); Print("Chart Scale = "+(string)result); } else if(result==3) { ChartSetInteger(0,CHART_SCALE,0,4); Print("Chart Scale = "+(string)result); } else if(result==4) { ChartSetInteger(0,CHART_SCALE,0,5); Print("Chart Scale = "+(string)result); } } } } //+------------------------------------------------------------------+ //| ZoomIN sparam | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| ZoomOUT sparam | //+------------------------------------------------------------------+ } //+------------------------------------------------------------------+ //| ZoomOUT sparam | //+------------------------------------------------------------------+
if(id==CHARTEVENT_OBJECT_CLICK) { if(sparam==Zin_Button) Zin_Toggle(); { if(ChartGetInteger(0,CHART_SCALE,0,result))
I missed the problem the first time. If you click on the Zout_Buttton, it calls Zout_Toggle, and then (for click on any object) it changes the scale. Fix your braces.For counting up, simplify Your code if(ChartGetInteger(0,CHART_SCALE,0,result)){ result = (result + 1) % 6; // 0, 1, 2, 3, 4, 5, 0... ChartSetInteger(0,CHART_SCALE,0,result); Print("Chart Scale = "+(string)result); }
if(ChartGetInteger(0,CHART_SCALE,0,result)) { if(result==0) { ChartSetInteger(0,CHART_SCALE,0,1);//Comment Print("Chart Scale = "+(string)result); } else if(result==1) :
For counting down, simplify Your code if(ChartGetInteger(0,CHART_SCALE,0,result)){ result = (result + 5) % 6; // 5, 4, 3, 2, 1, 0, 5... ChartSetInteger(0,CHART_SCALE,0,4); Print("Chart Scale = "+(string)result); }
if(ChartGetInteger(0,CHART_SCALE,0,result)) { if(result==5) { ChartSetInteger(0,CHART_SCALE,0,4);//Comment Print("Chart Scale = "+(string)result); } else if(result==4) :
Simply Your code Print("Chart Scale = ", result); //or PrintFormat("Chart Scale = %i", result);
Print("Chart Scale = "+(string)result);
WHRoeder:
- I missed the problem the first time. If you click on the Zout_Buttton, it calls Zout_Toggle, and then (for click on any object) it changes the scale. Fix your braces.
For counting up, simplify Your code For counting down, simplify Your code Simply Your code
Hi WHRoeder,
I have added your code but I still get the same problem. No Worries my head at the moment is like a brick.
BTW did you get a chance to load these buttons onto a chart together.
I will keep pocking a stick at it until I get a reaction I like.
Cheers and Thanks
Roddo

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
I have assembled a Chart Zoom Out Button for "CHART_SCALE" works just fine until I add the opposite condition Zoom In then they cancel each other out.
Could someone show or explain what I need to do to have them both in the same Indicator.
I have attached the both working Indicators so you can see what I have done.
Thank you
Rod