One Trade only//Hello Guys, how can I adjust this EA to enter one trade only /// and ifpossible how can i add 10 pips to the sl

Trade Operations in MQL5 - It's Easy
- www.mql5.com
Almost all traders come to market to make money but some traders also enjoy the process itself. However, it is not only manual trading that can provide you with an exciting experience. Automated trading systems development can also be quite absorbing. Creating a trading robot can be as interesting as reading a good mystery novel.
- iClose
- iLow
- iHigh
//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2020, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #include <Trade\Trade.mqh> CTrade trade; #define MAGIC 11 input int InpAddStopLoss = 100; // Add to Stop Loss (points) datetime prev_bar; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { prev_bar = 0; //--- Set Magic Number trade.SetExpertMagicNumber(MAGIC); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnTick() { int cnt, pos_nr = 0; datetime curr_bar; ulong ticket; //--- Gets the opening time of the current bar curr_bar = iTime(_Symbol, PERIOD_H4, 0); if(curr_bar == 0) { Print("Error getting current bar open time..."); return; } //============== CHECKS IF IS A NEW BAR... ===============// if(prev_bar != curr_bar && TimeCurrent() < curr_bar + 30) { //--- Checks positions for(cnt = PositionsTotal() - 1; cnt >= 0; cnt --) { //--- Gets the ticket and selects the position ticket = PositionGetTicket(cnt); if(ticket == 0) { Print("Failed to get position ticket..."); return; } if(PositionGetString(POSITION_SYMBOL) == _Symbol && PositionGetInteger(POSITION_MAGIC) == MAGIC) { pos_nr ++; break; } } if(pos_nr == 0) { //candle 1 double high1 = iHigh(_Symbol,PERIOD_H4,1); double low1 = iLow(_Symbol,PERIOD_H4,1); double close1 = iClose(_Symbol,PERIOD_H4,1); double open1 = iOpen(_Symbol,PERIOD_H4,1); //candle 2 double high2 = iHigh(_Symbol,PERIOD_H4,2); double low2 = iLow(_Symbol,PERIOD_H4,2); double close2 = iClose(_Symbol,PERIOD_H4,2); double open2 = iOpen(_Symbol,PERIOD_H4,2); if(low1 < low2 && close1 > high2 && close1 > open1) { double tp1= (close1-low1) + close1; trade.Buy(0.1,_Symbol,close1,low1-InpAddStopLoss*_Point,tp1); } if(high1 > high2 && close1 < low2 && close1 < open1) { double tp= (close1-high1) + close1; trade.Sell(0.1,_Symbol,close1,high1+InpAddStopLoss*_Point,tp); } } //--- Updates bar time prev_bar = curr_bar; } } //+------------------------------------------------------------------+

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