//+------------------------------------------------------------------+ //| ROBOTICSv1.1 | //| Azaan Hassan | //| www.kimi | //+------------------------------------------------------------------+ #property copyright "Azaan Hassan" #property link "www.kimi" #property version "1.00" #property strict // Define global variables double previousHigh = 0; double previousLow = 0; double retestValue = 0.003; // 3 pips int order; double initialBalance; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { // Save the initial account balance initialBalance = AccountBalance(); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { // Get current price, high, and low double currentPrice = SymbolInfoDouble(Symbol(), SYMBOL_BID); double currentHigh = iHigh(Symbol(), PERIOD_M5, 0); double currentLow = iLow(Symbol(), PERIOD_M5, 0); // Logging current values Print("Current Price: ", currentPrice); Print("Current High: ", currentHigh); Print("Current Low: ", currentLow); Print("Previous High: ", previousHigh); Print("Previous Low: ", previousLow); // Simulate structure break and retest 3 pips if(currentPrice < currentHigh && currentPrice + retestValue > previousHigh) { // Open a buy order with 15 pips take profit and 7.5 pips stop loss order = OrderSend(Symbol(), OP_BUY, 0.5, Ask, 3, Ask - 0.0005, Ask + 0.0025, "Buy Order", 0, 0, Green); if (order > 0) { previousHigh = currentHigh; } } else if(currentPrice > currentLow && currentPrice - retestValue < previousLow) { // Open a sell order with 15 pips take profit and 7.5 pips stop loss order = OrderSend(Symbol(), OP_SELL, 0.5, Ask, 3, Ask - 0.0005, Ask + 0.00250, "Sell Order", 0, 0, Red); if (order > 0) { previousLow = currentLow; } } // Check for 1% gain and stop the program double currentBalance = AccountBalance(); if (currentBalance >= initialBalance * 1.01) { Print("1% gain achieved. Stopping the program."); ExpertRemove(); } } //+------------------------------------------------------------------+