I need a few scalping strategies
Jump to turn (7)
- User
I need a few scalping strategies
- Assistant
I need a few scalping strategies
Sure! Scalping is a trading style focused on making small, quick profits by entering and exiting trades within very short time frames, often minutes or even seconds. Here are a few popular scalping strategies with explanations:
If you want, I can help you create a custom scalping plan based on your preferred market or trading platform!
Do you know win rates for this strategies?
The exact win rates for scalping strategies can vary widely depending on multiple factors, including:
That said, here are some general observations based on common trader experiences and academic/industry studies:
I want to make it automatic, like an mt5 expert advisor, which one should I pick ? Considering I use it on prop firm account
Great question! When automating scalping strategies on MetaTrader 5 (MT5) for a prop firm account, you’ll want a strategy that:
Why?
Indicators
Entry Rules
Exit Rules
Money Management
Filters (optional but useful)
Yes please
Great! Below is a basic MT5 Expert Advisor (EA) template implementing a simple Moving Average Cross Scalping strategy with these features:
Instead of fixed lot side, I want to set a Ballance and percentage
Sure! To use account balance and a risk percentage for dynamic position sizing based on stop loss distance, you calculate the lot size so that the maximum loss per trade does not exceed the specified risk percentage of your account balance.
(lot size) * (stop loss in money) = risk amount.RiskPercent instead of fixed LotSizeAdd this input at the top (replace LotSize input or keep both if you want flexibility):
input double RiskPercent = 1.0; // Risk per trade in percentage of account balance
Add a helper function to calculate lot size based on stop loss:
double CalculateLotSize(double stopLossPoints)
{
double tickValue, tickSize, lotStep, minLot, maxLot;
double riskAmount, lotSize;
// Get trading parameters
SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE, tickValue);
SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_SIZE, tickSize);
SymbolInfoInteger(Symbol(), SYMBOL_VOLUME_STEP, lotStep);
minLot = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN);
maxLot = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MAX);
// Money risk per trade
riskAmount = AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100.0;
// Calculate lot size
// Stop loss in money = stopLossPoints in points * tickValue per tickSize (price step)
// lotSize = riskAmount / stopLossMoney
// Convert points to price distance:
double stopLossPriceDistance = stopLossPoints * _Point;
double stopLossMoney = (stopLossPriceDistance / tickSize) * tickValue;
if(stopLossMoney <= 0)
return minLot; // or 0 if invalid
lotSize = riskAmount / stopLossMoney;
// Round lot size down to nearest lot step
lotSize = MathFloor(lotSize / lotStep) * lotStep;
if(lotSize < minLot)
lotSize = minLot;
if(lotSize > maxLot)
lotSize = maxLot;
return lotSize;
}
Please
Certainly! Below is the full updated MT5 Expert Advisor code integrating dynamic lot sizing based on account balance and risk percentage, using the previously provided Moving Average Cross scalping logic.
Can I set balance?
In MetaTrader 5, your account balance is determined by your broker, so you cannot manually set or change the balance within the EA. The EA reads the live/current account balance using functions like AccountInfoDouble(ACCOUNT_BALANCE).
AccountInfoDouble(ACCOUNT_BALANCE) when calculating lot size.SimulatedBalance is set to 0 or negative, fallback to real account balance.Add this input at the top:
input double SimulatedBalance = 0.0; // Set to >0 to simulate balance, 0 to use real account balance
Modify the CalculateLotSize() function's line:
// Replace this line
double riskAmount = AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100.0;
// By this
double usedBalance = (SimulatedBalance > 0.0) ? SimulatedBalance : AccountInfoDouble(ACCOUNT_BALANCE);
double riskAmount = usedBalance * RiskPercent / 100.0;
SimulatedBalance input.If you want me to provide the full updated EA code including this SimulatedBalance feature, just let me know!
If you want more precise numbers or tested statistics, I recommend backtesting these strategies on historical data or using demo accounts to derive win rates under your trading style and market conditions.
Start with a Moving Average Cross scalping EA with conservative fixed stops and profit targets on a 1 to 5-minute chart.
Add filters for trend and spread.
This approach balances simplicity, clarity, automation friendliness, and aligns well with prop firm risk constraints.
If you want, I can help you draft a basic MT5 EA template or provide MQL5 code snippets for this strategy. Would you like that?
//+------------------------------------------------------------------+
//| MA_Cross_Scalp |
//| Starter template |
//+------------------------------------------------------------------+
#property copyright "YourName"
#property version "1.00"
#property strict
// Input parameters
input int FastEMAPeriod = 5;
input int SlowEMAPeriod = 20;
input double LotSize = 0.1;
input int StopLoss = 50; // in points (5 pips if 1 pips = 10 points)
input int TakeProfit = 100; // in points
input int Slippage = 3;
input int MinHourTrade = 8; // Start trading from 08:00 server time
input int MaxHourTrade = 22; // Stop trading at 22:00 server time
input double MaxSpread = 15.0; // Maximum allowed spread in points (1.5 pips)
datetime lastTradeTime = 0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Check trading hours
datetime timeCurrent = TimeCurrent();
MqlDateTime tm;
TimeToStruct(timeCurrent,tm);
if(tm.hour < MinHourTrade || tm.hour >= MaxHourTrade)
return;
// Check spread
double spread_points = (Ask - Bid)/_Point;
if(spread_points > MaxSpread)
return;
// Calculate EMAs on current timeframe
double fastEMA = iMA(NULL,0,FastEMAPeriod,0,MODE_EMA,PRICE_CLOSE,0);
double slowEMA = iMA(NULL,0,SlowEMAPeriod,0,MODE_EMA,PRICE_CLOSE,0);
double fastEMA_prev = iMA(NULL,0,FastEMAPeriod,0,MODE_EMA,PRICE_CLOSE,1);
double slowEMA_prev = iMA(NULL,0,SlowEMAPeriod,0,MODE_EMA,PRICE_CLOSE,1);
// Check for existing open positions on symbol and filter
int totalPositions = PositionsTotal();
bool longPositionExists = false;
bool shortPositionExists = false;
for(int i=0; i<totalPositions; i++)
{
ulong ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
if(PositionGetString(POSITION_SYMBOL) == Symbol())
{
ENUM_POSITION_TYPE pos_type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
if(pos_type == POSITION_TYPE_BUY)
longPositionExists = true;
else if(pos_type == POSITION_TYPE_SELL)
shortPositionExists = true;
}
}
}
// Entry: check crossover
// Buy signal: fast EMA crosses above slow EMA
if(fastEMA_prev < slowEMA_prev && fastEMA > slowEMA && !longPositionExists)
{
// Close short positions if any
if(shortPositionExists)
ClosePositions(POSITION_TYPE_SELL);
// Open buy position
OpenPosition(ORDER_TYPE_BUY);
}
// Sell signal: fast EMA crosses below slow EMA
if(fastEMA_prev > slowEMA_prev && fastEMA < slowEMA && !shortPositionExists)
{
// Close long positions if any
if(longPositionExists)
ClosePositions(POSITION_TYPE_BUY);
// Open sell position
OpenPosition(ORDER_TYPE_SELL);
}
}
//+------------------------------------------------------------------+
//| Open position helper function |
//+------------------------------------------------------------------+
void OpenPosition(ENUM_ORDER_TYPE order_type)
{
MqlTradeRequest request;
MqlTradeResult result;
ZeroMemory(request);
ZeroMemory(result);
request.action = TRADE_ACTION_DEAL;
request.symbol = Symbol();
request.volume = LotSize;
request.type = order_type;
request.price = (order_type == ORDER_TYPE_BUY) ? SymbolInfoDouble(Symbol(), SYMBOL_ASK) : SymbolInfoDouble(Symbol(), SYMBOL_BID);
request.deviation= Slippage;
// Calculate stop loss and take profit
if(order_type == ORDER_TYPE_BUY)
{
request.sl = request.price - StopLoss * _Point;
request.tp = request.price + TakeProfit * _Point;
}
else if(order_type == ORDER_TYPE_SELL)
{
request.sl = request.price + StopLoss * _Point;
request.tp = request.price - TakeProfit * _Point;
}
if(!OrderSend(request,result))
{
Print("OrderSend failed: ", GetLastError());
}
else
{
Print("Opened position: ", order_type == ORDER_TYPE_BUY ? "BUY" : "SELL", " ticket: ", result.order);
}
}
//+------------------------------------------------------------------+
//| Close all positions helper function for given type |
//+------------------------------------------------------------------+
void ClosePositions(ENUM_POSITION_TYPE pos_type)
{
ulong ticket;
double price;
MqlTradeRequest request;
MqlTradeResult result;
for(int i=PositionsTotal()-1; i>=0; i--)
{
ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
if(PositionGetString(POSITION_SYMBOL) == Symbol() && PositionGetInteger(POSITION_TYPE) == pos_type)
{
ZeroMemory(request);
ZeroMemory(result);
request.action = TRADE_ACTION_DEAL;
request.position = ticket;
if(pos_type == POSITION_TYPE_BUY)
{
request.type = ORDER_TYPE_SELL;
price = SymbolInfoDouble(Symbol(), SYMBOL_BID);
}
else if(pos_type == POSITION_TYPE_SELL)
{
request.type = ORDER_TYPE_BUY;
price = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
}
request.price = price;
request.volume = PositionGetDouble(POSITION_VOLUME);
request.deviation = Slippage;
if(!OrderSend(request,result))
{
Print("Close failed: ", GetLastError());
}
else
{
Print("Closed position ticket ", ticket);
}
}
}
}
}
MetaEditor to create a new Expert Advisor.StopLoss, TakeProfit, LotSize, trading hours, and MaxSpread to fit your requirements.If you want, I can help with adding features such as position sizing by risk %, trailing stops, or advanced filters. Just let me know!
LotSize variable in the OpenPosition function with dynamically calculated lot size:Inside OpenPosition():
Replace:
request.volume = LotSize;
with:
double sl_points = StopLoss;
double calculatedLot = CalculateLotSize(sl_points);
if(calculatedLot < SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN))
{
Print("Calculated lot size too small, skipping trade.");
return; // Skip trade if lot size invalid
}
request.volume = calculatedLot;
RiskPercent input.CalculateLotSize() function.If you want, I can provide the full updated EA code with these changes integrated. Just let me know!
//+------------------------------------------------------------------+
//| MA_Cross_Scalp |
//| Starter template |
//+------------------------------------------------------------------+
#property copyright "YourName"
#property version "1.10"
#property strict
// Input parameters
input int FastEMAPeriod = 5;
input int SlowEMAPeriod = 20;
input double RiskPercent = 1.0; // Risk per trade in % of account balance
input int StopLoss = 50; // in points (e.g., 50 points = 5 pips if 1 pip = 10 points)
input int TakeProfit = 100; // in points
input int Slippage = 3;
input int MinHourTrade = 8; // Start trading from 08:00 server time
input int MaxHourTrade = 22; // Stop trading at 22:00 server time
input double MaxSpread = 15.0; // Maximum allowed spread in points (1.5 pips)
datetime lastTradeTime = 0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Check trading hours
datetime timeCurrent = TimeCurrent();
MqlDateTime tm;
TimeToStruct(timeCurrent,tm);
if(tm.hour < MinHourTrade || tm.hour >= MaxHourTrade)
return;
// Check spread
double spread_points = (Ask - Bid)/_Point;
if(spread_points > MaxSpread)
return;
// Calculate EMAs on current timeframe
double fastEMA = iMA(NULL,0,FastEMAPeriod,0,MODE_EMA,PRICE_CLOSE,0);
double slowEMA = iMA(NULL,0,SlowEMAPeriod,0,MODE_EMA,PRICE_CLOSE,0);
double fastEMA_prev = iMA(NULL,0,FastEMAPeriod,0,MODE_EMA,PRICE_CLOSE,1);
double slowEMA_prev = iMA(NULL,0,SlowEMAPeriod,0,MODE_EMA,PRICE_CLOSE,1);
// Check for existing open positions on symbol and filter
int totalPositions = PositionsTotal();
bool longPositionExists = false;
bool shortPositionExists = false;
for(int i=0; i<totalPositions; i++)
{
ulong ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
if(PositionGetString(POSITION_SYMBOL) == Symbol())
{
ENUM_POSITION_TYPE pos_type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
if(pos_type == POSITION_TYPE_BUY)
longPositionExists = true;
else if(pos_type == POSITION_TYPE_SELL)
shortPositionExists = true;
}
}
}
// Entry: check crossover
// Buy signal: fast EMA crosses above slow EMA
if(fastEMA_prev < slowEMA_prev && fastEMA > slowEMA && !longPositionExists)
{
// Close short positions if any
if(shortPositionExists)
ClosePositions(POSITION_TYPE_SELL);
// Open buy position
OpenPosition(ORDER_TYPE_BUY);
}
// Sell signal: fast EMA crosses below slow EMA
if(fastEMA_prev > slowEMA_prev && fastEMA < slowEMA && !shortPositionExists)
{
// Close long positions if any
if(longPositionExists)
ClosePositions(POSITION_TYPE_BUY);
// Open sell position
OpenPosition(ORDER_TYPE_SELL);
}
}
//+------------------------------------------------------------------+
//| Open position helper function |
//+------------------------------------------------------------------+
void OpenPosition(ENUM_ORDER_TYPE order_type)
{
double sl_points = StopLoss;
double calculatedLot = CalculateLotSize(sl_points);
// Validate lot size
double minLot = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN);
double maxLot = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MAX);
double lotStep = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_STEP);
if(calculatedLot < minLot)
{
Print("Calculated lot size too small: ", DoubleToString(calculatedLot,2), ". Skipping trade.");
return; // Skip trade if lot size invalid
}
if(calculatedLot > maxLot)
{
calculatedLot = maxLot;
Print("Calculated lot size exceeds max lot, set to max lot: ", maxLot);
}
// Round lot size down to nearest lot step
calculatedLot = MathFloor(calculatedLot / lotStep) * lotStep;
MqlTradeRequest request;
MqlTradeResult result;
ZeroMemory(request);
ZeroMemory(result);
request.action = TRADE_ACTION_DEAL;
request.symbol = Symbol();
request.volume = calculatedLot;
request.type = order_type;
request.price = (order_type == ORDER_TYPE_BUY) ? SymbolInfoDouble(Symbol(), SYMBOL_ASK) : SymbolInfoDouble(Symbol(), SYMBOL_BID);
request.deviation= Slippage;
// Calculate stop loss and take profit prices
if(order_type == ORDER_TYPE_BUY)
{
request.sl = request.price - StopLoss * _Point;
request.tp = request.price + TakeProfit * _Point;
}
else if(order_type == ORDER_TYPE_SELL)
{
request.sl = request.price + StopLoss * _Point;
request.tp = request.price - TakeProfit * _Point;
}
if(!OrderSend(request,result))
{
Print("OrderSend failed: ", GetLastError());
}
else
{
Print("Opened position: ", order_type == ORDER_TYPE_BUY ? "BUY" : "SELL", " ticket: ", result.order, " lots: ", DoubleToString(calculatedLot,2));
}
}
//+------------------------------------------------------------------+
//| Close all positions helper function for given type |
//+------------------------------------------------------------------+
void ClosePositions(ENUM_POSITION_TYPE pos_type)
{
ulong ticket;
double price;
MqlTradeRequest request;
MqlTradeResult result;
for(int i=PositionsTotal()-1; i>=0; i--)
{
ticket = PositionGetTicket(i);
if(PositionSelectByTicket(ticket))
{
if(PositionGetString(POSITION_SYMBOL) == Symbol() && PositionGetInteger(POSITION_TYPE) == pos_type)
{
ZeroMemory(request);
ZeroMemory(result);
request.action = TRADE_ACTION_DEAL;
request.position = ticket;
if(pos_type == POSITION_TYPE_BUY)
{
request.type = ORDER_TYPE_SELL;
price = SymbolInfoDouble(Symbol(), SYMBOL_BID);
}
else if(pos_type == POSITION_TYPE_SELL)
{
request.type = ORDER_TYPE_BUY;
price = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
}
request.price = price;
request.volume = PositionGetDouble(POSITION_VOLUME);
request.deviation = Slippage;
if(!OrderSend(request,result))
{
Print("Close failed: ", GetLastError());
}
else
{
Print("Closed position ticket ", ticket);
}
}
}
}
}
//+------------------------------------------------------------------+
//| Calculate lot size based on risk % and stop loss distance |
//+------------------------------------------------------------------+
double CalculateLotSize(double stopLossPoints)
{
double tickValue = 0.0;
double tickSize = 0.0;
double lotStep = 0.0;
double minLot = 0.0;
double maxLot = 0.0;
if(!SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE, tickValue) ||
!SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_SIZE, tickSize) ||
!SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_STEP, lotStep) ||
!SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN, minLot) ||
!SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MAX, maxLot))
{
Print("Failed to get symbol properties, using default lot size calculation");
return(minLot); // Default to minimum to avoid errors
}
// Risk amount in account currency
double riskAmount = AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100.0;
// Calculate stop loss in account currency per lot
double stopLossPriceDistance = stopLossPoints * _Point;
double stopLossMoney = (stopLossPriceDistance / tickSize) * tickValue;
if(stopLossMoney <= 0)
{
Print("Invalid stop loss money calculation.");
return(minLot);
}
double lotSize = riskAmount / stopLossMoney;
// Round down to nearest lot step & keep within limits
lotSize = MathFloor(lotSize / lotStep) * lotStep;
if(lotSize < minLot)
lotSize = minLot;
if(lotSize > maxLot)
lotSize = maxLot;
return lotSize;
}
RiskPercent input for your preferred risk (e.g. 0.5, 1, or 2% per trade).StopLoss and TakeProfit inputs to fit your strategy and instrument.MinHourTrade and MaxHourTrade to your preferred trading session.MaxSpread to control acceptable spread for live trades.If you want help adding trailing stop, time filters by day of week, or news filters, just say so!