I see. I check the location of the tenkan and the kinjun on the first and second candle. If there is a signal, I enter an alert. But I would like it to be a one time thing. Please help me. Here is the code.
I see. I check the location of the tenkan and the kinjun on the first and second candle. If there is a signal, I enter an alert. But I would like it to be a one time thing. Please help me. Here is the code.
Not more than one alert on one bar:
//+------------------------------------------------------------------+//| main_Ichimoku.mq5 |//| Copyright 2015, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2015, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"//+------------------------------------------------------------------+//| Объявим переменные для хранения настроек индикаторов |//+------------------------------------------------------------------+int IKHtenkansen=8;
int IKHkijunsen=24;
int IKHsenkouspanb=48;
//+------------------------------------------------------------------+//| Объявим переменные для хранения хэндлов индикаторов |//+------------------------------------------------------------------+int h_ich=INVALID_HANDLE;
//+------------------------------------------------------------------+//| Объявим необходимые массивы для хранения данных индикаторов |//+------------------------------------------------------------------+double ich1_buffer[];
double ich2_buffer[];
//+------------------------------------------------------------------+//| Объявим переменные для хранения сигналов индикаторов |//+------------------------------------------------------------------+int SignalICH;
//+------------------------------------------------------------------+//| Объявим переменную-флаг разрешения/запрета алерта |//+------------------------------------------------------------------+bool bool_alert=false;//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
staticdatetime prevtime=0;
datetime time_zero[];
CopyTime(Symbol(),Period(),0,1,time_zero);
if(!bool_alert)
if(prevtime!=time_zero[0])
bool_alert=true;
prevtime=time_zero[0];
SignalICH=TradeSignal_20();
Comment("SignalICH: "+(string)SignalICH);
}
//+------------------------------------------------------------------+//| Функция |//+------------------------------------------------------------------+int TradeSignal_20()
{
int sig=0;
if(h_ich==INVALID_HANDLE)
{
h_ich=iIchimoku(Symbol(),Period(),IKHtenkansen,IKHkijunsen,IKHsenkouspanb);
return(0);
}
else
{
if(CopyBuffer(h_ich,0,0,3,ich1_buffer)<2) return(0); // TENKANSEN_LINEif(CopyBuffer(h_ich,1,0,3,ich2_buffer)<2) return(0); // KIJUNSEN_LINEif(!ArraySetAsSeries(ich1_buffer,true)) return(0);
if(!ArraySetAsSeries(ich2_buffer,true)) return(0);
}
//--- проводим проверку условия и устанавливаем значение для sigif(ich1_buffer[1]>ich2_buffer[1]) sig=1;
elseif(ich1_buffer[1]<ich2_buffer[1]) sig=-1;
else sig=0;8
if(ich1_buffer[1]>ich2_buffer[1])
if(ich1_buffer[2]<ich2_buffer[2])
if(bool_alert)
{
Alert(Symbol()+": покупка");
//--- опускаем флаг
bool_alert=false;
}if(ich1_buffer[1]<ich2_buffer[1])
if(ich1_buffer[2]>ich2_buffer[2])
if(bool_alert)
{
Alert(Symbol()+": продажа");
//--- опускаем флаг
bool_alert=false;
}//--- возвращаем торговый сигналreturn (sig);
}
//+------------------------------------------------------------------+
How to make an EA to skip 1 signal after a losing trade? ( very good Z-strategy )
Explain in words, the code itself is able to implement.
At a loss give a certain value to the global variable of the terminal and reset it to zero at the first signal. The trading function monitors this value and decides whether to open a new trade or not.
In other words, the work order is approximately as follows:
a) Track profit;
b) count signals, check the checkbox in case of loss, if there is no other signal to trade yet, reset the checkbox when the first signal after the loss occurs;
c) check the box and decide whether to trade or wait.
It is more convenient to use GPT, they are saved when the terminal crashes, simple variables in the code can be reset by any sneeze and the Expert Advisor will work with errors.
At a loss, assign a certain value to the terminal's global variable and reset it to zero at the first signal. The trading function monitors this value and decides whether to open a new trade or not.
That is, the order of work is approximately the following:
a) Track profit;
b) count signals, check the box in case of a loss, if we haven't yet had another signal to trade, reset the box when the first signal comes in after a loss;
c) check the box and decide whether to trade or wait.
GPT is more convenient to use, they are saved when the terminal crashes, simple variables in the code can be reset by any sneeze and the Expert Advisor will work with errors.
All understood except one . How to make a signal counter?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
It's not clear what was meant?
I meant the following:Insert the code correctly in the forum
I see. I check the location of the tenkan and the kinjun on the first and second candle. If there is a signal, I enter an alert. But I would like it to be a one time thing. Please help me. Here is the code.
I see. I check the location of the tenkan and the kinjun on the first and second candle. If there is a signal, I enter an alert. But I would like it to be a one time thing. Please help me. Here is the code.
Not more than one alert on one bar:
There is no more than one alert per bar:
Hi All!
How to make an EA to skip 1 signal after a losing trade? ( very good Z-strategy )
Explain in words, the code itself is able to implement.
Hi All!
How to make an EA to skip 1 signal after a losing trade? ( very good Z-strategy )
Explain in words, the code itself is able to implement.
At a loss give a certain value to the global variable of the terminal and reset it to zero at the first signal. The trading function monitors this value and decides whether to open a new trade or not.
In other words, the work order is approximately as follows:
a) Track profit;
b) count signals, check the checkbox in case of loss, if there is no other signal to trade yet, reset the checkbox when the first signal after the loss occurs;
c) check the box and decide whether to trade or wait.
It is more convenient to use GPT, they are saved when the terminal crashes, simple variables in the code can be reset by any sneeze and the Expert Advisor will work with errors.
At a loss, assign a certain value to the terminal's global variable and reset it to zero at the first signal. The trading function monitors this value and decides whether to open a new trade or not.
That is, the order of work is approximately the following:
a) Track profit;
b) count signals, check the box in case of a loss, if we haven't yet had another signal to trade, reset the box when the first signal comes in after a loss;
c) check the box and decide whether to trade or wait.
GPT is more convenient to use, they are saved when the terminal crashes, simple variables in the code can be reset by any sneeze and the Expert Advisor will work with errors.
Got it all but one . How to make a signal counter?
spits
sl = NormalizeDouble(sl,MarketInfo(symbol,MODE_DIGITS));possible loss of data due to type conversion .mq4 1697 29
type Doble at SL.