Hello, I have a few questions about the code I’m pasting below. I used Algowizard to make a template for a simple Donchian channel breakout strategy. Here are my questions:
-I understand the StopLossCoef- this is how my stop loss is calculated. But what is
//——————————————————————–
// Pseudo Source Code of Strategy 0.312
//
// Generated by StrategyQuant X Build 142 for MetaTrader
// at 03/12/2025 16:03
//
// Backtested on _M6E.B / D1, 1999.01.04 – 2014.12.31
// Backtest engine: Tradestation
//——————————————————————–
//——————————————————————–
// Strategy Parameters
//——————————————————————–
int MagicNumber = 11111;
double SSM = 1;
double LSM = 1;
int Period1 = 150;
int Period2 = 140;
int Period3 = 170;
int Period4 = 40;
double AssignVrbVleEntMlt1 = 7.5;
double StopLossCoef1 = 2.1;
double AssignVrbVleEntMlt2 = 3;
Main chart = Current Symbol / Current TF;
//——————————————————————–
// Trading options logic
//——————————————————————–
Don’t Trade On Weekends = false (Friday 0038 – Sunday 0038);
Exit at End Of Day = false (2304);
Exit On Friday = false (2200);
LimitSignalsTimeRange = false (0800 – 1600, Exit at End: false, Orders to close: All);
LimitMaxDistanceFromMarketPrice = false; //Limit max distance
MaxDistanceFromMarketPct = 6; //Max distance %
MaxTradesPerDay = 1;
Min SL: 0, Max SL: 0, Min PT: 0, Max PT: 0; // in ticks/pips, 0 means unlimited
//——————————————————————–
// Trading rule: Trading signals (On Bar Open)
//——————————————————————–
LongEntrySignal = ((Close(Main chart)[0] > Highest(Main chart, Period1, PRICE_CLOSE)[1])
and (Close(Main chart)[1] < Highest(Main chart, Period1, PRICE_CLOSE)[2]));
LongExitSignal = (Close(Main chart)[0] < Lowest(Main chart, Period2, PRICE_CLOSE)[1]);
ShortEntrySignal = ((Close(Main chart)[0] < Lowest(Main chart, Period3, PRICE_CLOSE)[1])
and (Close(Main chart)[1] > Lowest(Main chart, Period3, PRICE_CLOSE)[2]));
ShortExitSignal = (Close(Main chart)[0] > Highest(Main chart, Period4, PRICE_CLOSE)[1]);
//——————————————————————–
// Trading rule: Long entry (On Bar Open)
//——————————————————————–
if ((LongEntrySignal
and Not ShortEntrySignal)
and Not LongExitSignal)
{
// Action #1
LSM = AssignVrbVleEntMlt1;
// Action #2
Open Long order at Market;
Duplicate trades: disabled;
Stop Loss = StopLossCoef1 * ATR(20);
}
//——————————————————————–
// Trading rule: Short entry (On Bar Open)
//——————————————————————–
if ((ShortEntrySignal
and Not LongEntrySignal)
and Not ShortExitSignal)
{
// Action #1
SSM = AssignVrbVleEntMlt2;
// Action #2
Open Short order at Market;
Duplicate trades: disabled;
Stop Loss = StopLossCoef1 * ATR(20);
}
//——————————————————————–
// Trading rule: Long exit (On Bar Open)
//——————————————————————–
if (LongExitSignal
and (MarketPosition(“Current”, MagicNumber, “”) is Long))
{
// Action #1
Close Full position for Symbol = Current and Magic Number = MagicNumber;
}
//——————————————————————–
// Trading rule: Short exit (On Bar Open)
//——————————————————————–
if (ShortExitSignal
and (MarketPosition(“Current”, MagicNumber, “”) is Short))
{
// Action #1
Close Full position for Symbol = Current and Magic Number = MagicNumber;
}
Broker: No filter