Download MetaTrader 5

Get the current price?

To add comments, please log in or register
salexes
783
salexes  

Hi,

how do I get the current Price, 2 seconds before the current candle closes?

I am using the M1 Charts 

I want to do the following:

I have an open CALL on the current candle and if the Price 2 secconds before the candle is closed, is lower than the price was when the position was opened, then I want to open a new trade at that moment (or at the beginning of the next candle) in the opposite direction.

 My attempt:

   if
//( WRITE YOUR PUT RULES HERE )
   ( cross==-1 && warpDown==1 )
     {
      warpDown=0;
      pIsDirectionUp=false;
      return true;
      if(TimeCurrent() >= Time[0] + 58 && PRICE2SECONDSBEFORECLOSING> mPutPrice)
      {
               pIsDirectionUp=true;
               return true;
      }
     }

//****
// WRITE HERE THE CONDITION FOR OPENING A CALL BO
// Ex : if (RSI4>90.0)
//****

   if
//( WRITE YOUR CALL RULES HERE )
   ( cross==1 && warpUp==1)
     {
      warpUp=0;
      pIsDirectionUp=true;
      return true;
      if(TimeCurrent() >= Time[0] + 58 && PRICE2SECONDSBEFORECLOSING< mCallPrice)
      {
            pIsDirectionUp=false;
            return true;
      }
     }

   return false;
  }


I am writing an EA for trading binary options. I am using this: www.binaryoptionsedge.com/topic/3288-ea-backtest-binary-options-strategies-easily/ 

regards,

salexes 

whroeder1
16112
whroeder1  
Can't be done in OnTick, as there may be no ticks for minutes - "Free-of-Holes" Charts - MQL4 Articles.

Only in OnTimer and you can't use TimeCurrent, but must estimate server time. See 'Zero Lag Timer' indicator by 'madhatt30' for MetaTrader 4 and my comment/attachment at Indicators: Zero Lag Timer - Articles, Library comments - MQL5 programming forum
To add comments, please log in or register