Why do you think bool-logic doesn't work.
I think your code is broken - fix it.
The code without this filter works but if I add this line and imposed "false" does not work.
The written code so okay?
The written code so okay?
You don't fix it and you don't show it.
And now?
You're right ... sorry guys my code is this....I would like to turn on or off this filter code:
//--- indicator settings #property indicator_chart_window #property indicator_buffers 6 #property indicator_type1 DRAW_ARROW #property indicator_width1 1 #property indicator_color1 White #property indicator_label1 "Sell" #property indicator_type2 DRAW_ARROW #property indicator_width2 1 #property indicator_color2 White #property indicator_label2 "Buy" #property indicator_type3 DRAW_ARROW #property indicator_width3 1 #property indicator_color3 Yellow #property indicator_label3 "Sell" #property indicator_type4 DRAW_ARROW #property indicator_width4 1 #property indicator_color4 Yellow #property indicator_label4 "Buy" #property indicator_type5 DRAW_ARROW #property indicator_width5 1 #property indicator_color5 DarkViolet #property indicator_label5 "Sell" #property indicator_type6 DRAW_ARROW #property indicator_width6 1 #property indicator_color6 DarkViolet #property indicator_label6 "Buy" //--- indicator buffers double Buffer1[]; double Buffer2[]; double Buffer3[]; double Buffer4[]; double Buffer5[]; double Buffer6[]; extern double DojiGap2_ = 0.2; extern double RSI_Sell_1_InferioreA_= 100; extern double RSI_Sell_1_SuperioreA_= 80; extern double RSI_Sell_2_InferioreA_= 80; extern double RSI_Buy1_InferioreA_ = 20; extern double RSI_Buy1_SuperioreA_ = 0; extern double RSI_Buy2_SuperioreA_ = 20; extern double DojiGap2 = 0.2; extern double GapMM = 1; extern double RSI_Sell_1_InferioreA = 100; extern double RSI_Sell_1_SuperioreA = 80; extern double RSI_Sell_2_InferioreA = 80; extern double RSI_Buy1_InferioreA = 20; extern double RSI_Buy1_SuperioreA = 0; extern double RSI_Buy2_SuperioreA = 20; extern double GapAOpositivo = 0.000020; extern double GapAOnegativo = -0.000020; extern double DistanzaIcona = 1; extern bool Audible_Alerts = true; extern bool Filter = true; // I declare Filter true or false datetime time_alert; //used when sending alert double myPoint; //initialized in OnInit void myAlert(string type, string message) { if(type == "print") Print(message); else if(type == "error") { Print(type+" | Gol @ "+Symbol()+","+Period()+" | "+message); } else if(type == "order") { } else if(type == "modify") { } else if(type == "indicator") { if(Audible_Alerts) Alert(type+" | Gol @ "+Symbol()+","+Period()+" | "+message); } } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorBuffers(6); SetIndexBuffer(0, Buffer1); SetIndexEmptyValue(0, 0); SetIndexArrow(0, 242); SetIndexBuffer(1, Buffer2); SetIndexEmptyValue(1, 0); SetIndexArrow(1, 241); SetIndexBuffer(2, Buffer3); SetIndexEmptyValue(2, 0); SetIndexArrow(2, 159); SetIndexBuffer(3, Buffer4); SetIndexEmptyValue(3, 0); SetIndexArrow(3, 159); SetIndexBuffer(4, Buffer5); SetIndexEmptyValue(4, 0); SetIndexArrow(4, 242); SetIndexBuffer(5, Buffer6); SetIndexEmptyValue(5, 0); SetIndexArrow(5, 241); //initialize myPoint myPoint = Point(); if(Digits() == 5 || Digits() == 3) { myPoint *= 10; } return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[]) { int limit = rates_total - prev_calculated; //--- counting from 0 to rates_total ArraySetAsSeries(Buffer1, true); ArraySetAsSeries(Buffer2, true); ArraySetAsSeries(Buffer3, true); ArraySetAsSeries(Buffer4, true); ArraySetAsSeries(Buffer5, true); ArraySetAsSeries(Buffer6, true); //--- initial zero if(prev_calculated < 1) { ArrayInitialize(Buffer1, 0); ArrayInitialize(Buffer2, 0); ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); ArrayInitialize(Buffer5, 0); ArrayInitialize(Buffer6, 0); } else limit++; //--- main loop for(int i = limit-1; i >= 0; i--) { if (i >= MathMin(500000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation //Indicator Buffer 1 Sell if(Open[2+i] < Close[2+i] // Candela Verde && Open[1+i] < Close[1+i] // Candela Verde && MathAbs(Close[2+i] -Open [2+i]) > DojiGap2_ * myPoint // Corpo Candela Verde 2 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < RSI_Sell_1_InferioreA_ // Candela 1 < 100 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > RSI_Sell_1_SuperioreA_ // Candela 1 > 80 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) < RSI_Sell_2_InferioreA_ // Candela 2 < 80 && (Filter) && iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) < GapAOnegativo ) { Buffer1[i] = High[i] + DistanzaIcona * myPoint; ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); } else { if(Open[2+i] > Close[2+i] // Candela Rossa && Open[1+i] < Close[1+i] // Candela Verde && MathAbs(Open [2+i] -Close[2+i]) > DojiGap2_ * myPoint // Corpo Candela Rossa 2 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < RSI_Sell_1_InferioreA_ // Candela 1 < 100 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > RSI_Sell_1_SuperioreA_ // Candela 1 > 80 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) < RSI_Sell_2_InferioreA // Candela 2 < 80 && (Filter) && iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) < GapAOnegativo ) { Buffer1[i] = High[i] + DistanzaIcona * myPoint; ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); } } //Indicator Buffer 2 Buy if(Open[2+i] > Close[2+i] // Candela Rossa && Open[1+i] > Close[1+i] // Candela Rossa && MathAbs(Open [2+i] -Close[2+i]) > DojiGap2_ * myPoint // Corpo Candela Rossa 2 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > RSI_Buy1_SuperioreA_ // Candela 1 > 00 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < RSI_Buy1_InferioreA_ // Candela 1 < 20 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) > RSI_Buy2_SuperioreA_ // Candela 2 > 20 && (Filter) &&iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) > GapAOpositivo ) { Buffer2[i] = Low[i] - DistanzaIcona * myPoint; ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); } else { if(Open[2+i] < Close[2+i] // Candela Verde && Open[1+i] > Close[1+i] // Candela Rossa && MathAbs(Close[2+i] -Open [2+i]) > DojiGap2_ * myPoint // Corpo Candela Verde 2 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > RSI_Buy1_SuperioreA_ // Candela 1 > 00 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < RSI_Buy1_InferioreA_ // Candela 1 < 20 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) > RSI_Buy2_SuperioreA_ // Candela 2 > 20 && (Filter) &&iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) > GapAOpositivo ) { Buffer2[i] = Low[i] - DistanzaIcona * myPoint; ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); } } //Indicator Buffer 3 Pre-Sell if(Open[1+i] < Close[1+i] // Candela Verde && MathAbs(Close[1+i] -Open [1+i]) > DojiGap2_ * myPoint // Corpo Candela Verde 1 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) > 75 // Candela 1 > 75 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < 80 // Candela 2 < 80 ) { Buffer3[i] = High[i] + DistanzaIcona * myPoint; if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar } else { if(Open[1+i] > Close[1+i] // Candela Rossa && MathAbs(Open [1+i] -Close[1+i]) > DojiGap2_ * myPoint // Corpo Candela Rossa 1 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) > 75 // Candela 1 > 75 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < 80 // Candela 2 < 80 ) { Buffer3[i] = High[i] + DistanzaIcona * myPoint; if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar } } //Indicator Buffer 4 Pre-Buy if(Open[1+i] > Close[1+i] // Candela Rossa && MathAbs(Open [1+i] -Close[1+i]) > DojiGap2_ * myPoint // Corpo Candela Rossa 2 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) < 25 // Candela 1 < 25 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > 20 // Candela 2 > 20 ) { Buffer4[i] = Low[i] - DistanzaIcona * myPoint; if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar } else { if(Open[1+i] < Close[1+i] // Candela Verde && MathAbs(Close[1+i] -Open [1+i]) > DojiGap2_ * myPoint // Corpo Candela Verde 2 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) < 25 // Candela 1 < 25 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > 20 // Candela 2 > 20 ) { Buffer4[i] = Low[i] - DistanzaIcona * myPoint; if(i == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar } } //Indicator Buffer 5 Sell if(Open[2+i] < Close[2+i] // Candela Verde && Open[1+i] < Close[1+i] // Candela Verde && MathAbs(Close[2+i] -Open [2+i]) > DojiGap2 * myPoint && Close[1+i] > iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, 1+i) && MathAbs (Close[1+i]-iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, 1+i)) > GapMM * myPoint && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < RSI_Sell_1_InferioreA // Candela 1 < 100 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > RSI_Sell_1_SuperioreA // Candela 1 > 80 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) < RSI_Sell_2_InferioreA // Candela 2 < 80 && (Filter) && iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) < GapAOnegativo ) { Buffer5[i] = High[i] + DistanzaIcona * myPoint; ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); } else { if(Open[2+i] > Close[2+i] // Candela Rossa && Open[1+i] < Close[1+i] // Candela Verde && MathAbs(Open [2+i] -Close[2+i]) > DojiGap2 * myPoint // Corpo Candela Rossa 2 && Close[1+i] > iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, 1+i) && MathAbs (Close[1+i]-iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, 1+i)) > GapMM * myPoint && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < RSI_Sell_1_InferioreA // Candela 1 < 100 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > RSI_Sell_1_SuperioreA // Candela 1 > 80 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) < RSI_Sell_2_InferioreA // Candela 2 < 80 && (Filter) && iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) < GapAOnegativo ) { Buffer5[i] = High[i] + DistanzaIcona * myPoint; ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); } } //Indicator Buffer 6 Buy if(Open[2+i] > Close[2+i] // Candela Rossa && Open[1+i] > Close[1+i] // Candela Rossa && MathAbs(Open [2+i] -Close[2+i]) > DojiGap2 * myPoint // Corpo Candela Rossa 2 && Close[1+i] < iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, 1+i) && MathAbs (iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, 1+i)-Close[1+i]) > GapMM * myPoint && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > RSI_Buy1_SuperioreA // Candela 1 > 00 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < RSI_Buy1_InferioreA // Candela 1 < 20 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) > RSI_Buy2_SuperioreA // Candela 2 > 20 && (Filter) && iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) > GapAOpositivo ) { Buffer6[i] = Low[i] - DistanzaIcona * myPoint; ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); } else { if(Open[2+i] < Close[2+i] // Candela Verde && Open[1+i] > Close[1+i] // Candela Rossa && MathAbs(Close[2+i] -Open [2+i]) > DojiGap2 * myPoint // Corpo Candela Verde 2 && Close[1+i] < iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, 1+i) && MathAbs (iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, 1+i)-Close[1+i]) > GapMM * myPoint && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > RSI_Buy1_SuperioreA // Candela 1 > 00 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < RSI_Buy1_InferioreA // Candela 1 < 20 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) > RSI_Buy2_SuperioreA // Candela 2 > 20 && (Filter) && iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) > GapAOpositivo ) { Buffer6[i] = Low[i] - DistanzaIcona * myPoint; ArrayInitialize(Buffer3, 0); ArrayInitialize(Buffer4, 0); } } } return(rates_total); } //+------------------------------------------------------------------+
fly7680: I would like to turn on or off this filter code:
&& (Filter) && iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) > GapAOpositivo
As written if Filter is false, the entire if statement is false.
What you want is to add the iCustom if the filter is true. Try:
&& (!Filter || iCustom(NULL, PERIOD_CURRENT, "Awesome", 0, 1+i) > GapAOpositivo)

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
hello everyone, I have created a true / false filter, if it is active is ok, but does not work if disabled.