QuoteDislikedAllow opening only one order at time
Inserted Code
#property copyright "Copyright 2019, MyCompany" #property link "https://www.mycompany.com" #property version "1.00" #property strict input double StopLoss = 100.0; input double TakeProfit = 200.0; input double DipPercent = 5.0; int OnInit() { // Initialize the expert return(INIT_SUCCEEDED); } void OnTick() { // Check if the bar has just opened if (TimeCurrent() == Time[0]) { // Calculate the dip percentage double dip = (Low[1] - Low[2]) / Low[2] * 100; // Check if the current price is below the previous low by the dip percentage if (dip >= DipPercent) { // Check if there is already an open order if (OrdersTotal() == 0) { // If it is, buy at market price OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask - StopLoss * Point, Ask + TakeProfit * Point); } } // Check if the stop loss or take profit levels have been reached for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY) { if (Bid <= OrderStopLoss() || Bid >= OrderTakeProfit()) { OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE); } } } } } }