I'm currently learning the very basics of writing EA's, and have a quick question. I've tried creating an EA that gives an alert after a doji has formed, using the code
However, if there is a doji, this gives an alert every time there is a new tick. How can I get this to alert me ONCE PER OCCURRENCE of a doji candlestick?
Thanks
Inserted Code
//+------------------------------------------------------------------+ //| test2.mq4 | //| 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" #property strict //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- double body = Open[1]-Close[1]; double bodyabs = MathAbs(body); if(bodyabs <= 0.00050) { Alert("Doji"); } } //+------------------------------------------------------------------+
However, if there is a doji, this gives an alert every time there is a new tick. How can I get this to alert me ONCE PER OCCURRENCE of a doji candlestick?
Thanks