0% found this document useful (0 votes)
87 views2 pages

Skalping Enko

The document is a MetaTrader 5 (MT5) expert advisor script for scalping, utilizing moving averages and RSI for trading signals. It initializes indicators, checks for buy and sell signals based on crossovers and RSI levels, and executes trades accordingly. The script includes error handling for indicator creation and trade execution.

Uploaded by

eniskrasniqi1510
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views2 pages

Skalping Enko

The document is a MetaTrader 5 (MT5) expert advisor script for scalping, utilizing moving averages and RSI for trading signals. It initializes indicators, checks for buy and sell signals based on crossovers and RSI levels, and executes trades accordingly. The script includes error handling for indicator creation and trade execution.

Uploaded by

eniskrasniqi1510
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//+------------------------------------------------------------------+

//| Scalping_Enko.mq5 |
//| Copyright 2025, xAI |
//| Modified by Grok 3 |
//+------------------------------------------------------------------+

#property copyright "Copyright 2025, xAI"


#property link "https://x.ai"
#property version "1.00"
#property strict

// Input parameters
input double LotSize = 0.1; // Lot Size
input int FastMAPeriod = 5; // Fast MA Period
input int SlowMAPeriod = 20; // Slow MA Period
input int RSIPeriod = 14; // RSI Period
input int Slippage = 3; // Slippage in points (in points, not pips)

// Include necessary files


#include <Trade\Trade.mqh>

// Global variables
int handleFastMA = 0; // Handle for Fast Moving Average
int handleSlowMA = 0; // Handle for Slow Moving Average
int handleRSI = 0; // Handle for RSI
CTrade trade; // Trade object for order execution

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
// Create indicators
handleFastMA = iMA(NULL, 0, FastMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
handleSlowMA = iMA(NULL, 0, SlowMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
handleRSI = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE);

if(handleFastMA == INVALID_HANDLE || handleSlowMA == INVALID_HANDLE || handleRSI


== INVALID_HANDLE)
{
Print("Failed to create indicators. Error: ", GetLastError());
return INIT_FAILED;
}

return INIT_SUCCEEDED;
}

//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
// Release indicators
if(handleFastMA != INVALID_HANDLE) IndicatorRelease(handleFastMA);
if(handleSlowMA != INVALID_HANDLE) IndicatorRelease(handleSlowMA);
if(handleRSI != INVALID_HANDLE) IndicatorRelease(handleRSI);
}

//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Get the current symbol and timeframe
string symbol = Symbol();
ENUM_TIMEFRAMES timeframe = PERIOD_M1; // Scalping on 1-minute timeframe

// Get indicator buffers


double fastMA[], slowMA[], rsi[];
ArraySetAsSeries(fastMA, true);
ArraySetAsSeries(slowMA, true);
ArraySetAsSeries(rsi, true);

// Copy indicator values


if(CopyBuffer(handleFastMA, 0, 0, 3, fastMA) < 0 ||
CopyBuffer(handleSlowMA, 0, 0, 3, slowMA) < 0 ||
CopyBuffer(handleRSI, 0, 0, 3, rsi) < 0)
{
Print("Failed to copy indicator buffers. Error: ", GetLastError());
return;
}

// Get current price


double ask = SymbolInfoDouble(symbol, SYMBOL_ASK);
double bid = SymbolInfoDouble(symbol, SYMBOL_BID);

// Trading logic
bool buySignal = false;
bool sellSignal = false;

// Check for crossovers and RSI


if(fastMA[1] > slowMA[1] && fastMA[2] <= slowMA[2] && rsi[1] < 70) // Buy signal
buySignal = true;
if(fastMA[1] < slowMA[1] && fastMA[2] >= slowMA[2] && rsi[1] > 30) // Sell
signal
sellSignal = true;

// Execute trades (only if no positions are open)


if(buySignal && PositionsTotal() == 0)
{
if(trade.Buy(LotSize, symbol, ask, 0, 0, "Scalping Buy"))
Print("Buy order executed successfully");
else
Print("Buy order failed. Error: ", GetLastError());
}

if(sellSignal && PositionsTotal() == 0)


{
if(trade.Sell(LotSize, symbol, bid, 0, 0, "Scalping Sell"))
Print("Sell order executed successfully");
else
Print("Sell order failed. Error: ", GetLastError());
}
}

//+------------------------------------------------------------------+

You might also like