convert the following EA into a grid trend maultipyler EA 






//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
#property copyright "O"
#property version "1.00"
#property strict

// Declare input variables
input double LotSize = 0.01; // Lot size
input int TP_Points = 100; // Take profit in points
input int SL_Points = 100; // Stop loss in points
input int TradeHour = 1; // Hour to trade (server time)
input ulong MagicNumber = 123456; // Magic number for trades

// Declare global variables
datetime lastTradeTime = 0;

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
 Print("Daily Trader Simple EA initialized");
 MathSrand((uint)GetTickCount());
 return INIT_SUCCEEDED;
}

//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
 datetime current = TimeCurrent();
 MqlDateTime now;
 TimeToStruct(current, now);

// Define parameters for moving averages
 int shortMAPeriod = 10;
 int longMAPeriod = 50;

// Get the handles for the moving averages
 int shortMAHandle = iMA(NULL, 0, shortMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
 int longMAHandle = iMA(NULL, 0, longMAPeriod, 0, MODE_SMA, PRICE_CLOSE);

// Get the values of the moving averages
 double shortMAValues[2], longMAValues[2];
 CopyBuffer(shortMAHandle, 0, 0, 2, shortMAValues);
 CopyBuffer(longMAHandle, 0, 0, 2, longMAValues);

// Check for crossover
 bool buySignal = (shortMAValues[1] <= longMAValues[1]) && (shortMAValues[0] > longMAValues[0]);
 bool sellSignal = (shortMAValues[1] >= longMAValues[1]) && (shortMAValues[0] < longMAValues[0]);

 if (buySignal || sellSignal)
 {
 if (!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
 {
 Print("Trading currently not allowed");
 return;
 }

 ENUM_ORDER_TYPE orderType = buySignal ? ORDER_TYPE_BUY : ORDER_TYPE_SELL;
 string symbol = _Symbol;
 double price = (orderType == ORDER_TYPE_BUY) ? SymbolInfoDouble(symbol, SYMBOL_ASK) : SymbolInfoDouble(symbol, SYMBOL_BID);
 double point = SymbolInfoDouble(symbol, SYMBOL_POINT);
 int digits = (int)SymbolInfoInteger(symbol, SYMBOL_DIGITS);
 double sl = 0.0, tp = 0.0;

 if (SL_Points > 0)
 sl = (orderType == ORDER_TYPE_BUY) ? price - SL_Points * point : price + SL_Points * point;
 if (TP_Points > 0)
 tp = (orderType == ORDER_TYPE_BUY) ? price + TP_Points * point : price - TP_Points * point;

 sl = NormalizeDouble(sl, digits);
 tp = NormalizeDouble(tp, digits);

 MqlTradeRequest request;
 MqlTradeResult result;
 ZeroMemory(request);
 ZeroMemory(result);

 request.action = TRADE_ACTION_DEAL;
 request.symbol = symbol;
 request.volume = LotSize;
 request.type = orderType;
 request.price = NormalizeDouble(price, digits);
 request.deviation = 10;
 request.magic = MagicNumber;
 request.type_filling = ORDER_FILLING_FOK;

 if (!OrderSend(request, result))
 {
 PrintFormat("OrderSend failed: retcode=%d, comment=%s", result.retcode, result.comment);
 return;
 }
 else
 {
 PrintFormat("Order opened successfully! Ticket: %I64u", result.order);
 lastTradeTime = current;

 if (SL_Points > 0 || TP_Points > 0)
 {
 MqlTradeRequest modifyRequest;
 MqlTradeResult modifyResult;
 ZeroMemory(modifyRequest);
 ZeroMemory(modifyResult);

 modifyRequest.action = TRADE_ACTION_SLTP;
 modifyRequest.position = result.order;
 modifyRequest.symbol = symbol;
 if (SL_Points > 0) modifyRequest.sl = sl;
 if (TP_Points > 0) modifyRequest.tp = tp;

 if (!OrderSend(modifyRequest, modifyResult))
 PrintFormat("Failed to set SL/TP. retcode=%d comment=%s", modifyResult.retcode, modifyResult.comment);
 else
 Print("SL and TP set successfully.");
 }
 }
 }
}