Try as follows;
for (int i = limit - 1; i >= 0; i--) { //Calculates each MA Label1Buffer[i] = iMA(NULL, 0, 14, 0, 0, 0, i); Label2Buffer[i] = iMA(NULL, 0, 28, 0, 0, 0, i); }
if (id == CHARTEVENT_OBJECT_CLICK && sparam == "MA14Button") { SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, clrWhite); SetIndexStyle(1, DRAW_NONE, STYLE_SOLID, 1, clrNONE); } if (id == CHARTEVENT_OBJECT_CLICK && sparam == "MA28Button") { SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1, clrRed); SetIndexStyle(0, DRAW_NONE, STYLE_SOLID, 1, clrNONE); }
You are awesome!!!
I wanted to show both of them if the case, not only switch one to other, I took your advise and got this. works awesome
Thank you!!
if (id == CHARTEVENT_OBJECT_CLICK && sparam == "MA14Button") { switch (MA14_Ind) { case (true): SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, clrRed); MA14_Ind=false; break; case (false): SetIndexStyle(0, DRAW_NONE, STYLE_SOLID, 1, clrNONE); MA14_Ind=true; break; } } if (id == CHARTEVENT_OBJECT_CLICK && sparam == "MA28Button") { switch (MA28_Ind) { case (true): SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1, clrWhite); MA28_Ind=false; break; case (false): SetIndexStyle(1, DRAW_NONE, STYLE_SOLID, 1, clrNONE); MA28_Ind=true; break; } }

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 tryin to easy show/hide indicators on the chart window, better that switch templates, I think. I did the interface and the buttons for each one, this example is with easy moving averages, but I think can be used for Ichimoku, BBands, etc, please check on the screen shot.
I have the buttons done, but my problem is the linking Boolean variables to define the show/hide, as well as the logic to execute it. Please check on my code, I tied with some variables but cant get linked batwing OnCalculate and OnChartEvent
Thank you