//--------------------------------------------------------------------
// Pseudo Source Code of GJ_H1_220100100_S_EM_CF_SQX
//
//   Generated by StrategyQuant X Build 142 for MetaTrader
//   at 09/23/2025 17:50
//
//   Backtested on GBPJPY_M1_UTCPlus02 / H1, 2003.08.04 - 2021.03.25
//   Backtest engine: MetaTrader4
//--------------------------------------------------------------------

//--------------------------------------------------------------------
//  Strategy Parameters
//--------------------------------------------------------------------
int MagicNumber = 220100100;
int BBBarOpensPeriod1 = 20;
double PriceEntryMult1 = 2.6;
double ProfitTarget1 = 365;
double StopLoss1 = 135;
int EMAPeriod1 = 30;
int ATRPeriod1 = 14;

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 = true (2000);
LimitSignalsTimeRange = false (0800 - 1600, Exit at End: false, Orders to close: All);
LimitMaxDistanceFromMarketPrice = false;   //Limit max distance
MaxDistanceFromMarketPct = 6;   //Max distance %
MaxTradesPerDay = 0;
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 = (Open below BollingerBands(Main chart,BBBarOpensPeriod1, 2, PRICE_CLOSE).LowerBand after opened above)[0]
;

ShortEntrySignal = (Open above BollingerBands(Main chart,BBBarOpensPeriod1, 2, PRICE_CLOSE).UpperBand after opened below)[0]
;

LongExitSignal = false;

ShortExitSignal = false;


//--------------------------------------------------------------------
// Trading rule: Long entry (On Bar Open)
//--------------------------------------------------------------------           
if LongEntrySignal
{
    // Action #1
    Open Long order at (EMA(Main chart,EMAPeriod1, PRICE_CLOSE)[2] + (PriceEntryMult1 * ATR(Main chart,ATRPeriod1)[3])) Stop;
        Order valid for 13 bars;
        Duplicate trades: disabled; 
        Replacing pending orders: allowed; 
        Stop Loss = StopLoss1 pips;
        Profit target = ProfitTarget1 pips;
}

//--------------------------------------------------------------------
// Trading rule: Short entry (On Bar Open)
//--------------------------------------------------------------------           
if (ShortEntrySignal
   and Not LongEntrySignal)
{
    // Action #1
    Open Short order at (EMA(Main chart,EMAPeriod1, PRICE_CLOSE)[2] - (PriceEntryMult1 * ATR(Main chart,ATRPeriod1)[3])) Stop;
        Order valid for 13 bars;
        Duplicate trades: disabled; 
        Replacing pending orders: allowed; 
        Stop Loss = StopLoss1 pips;
        Profit target = ProfitTarget1 pips;
}

//--------------------------------------------------------------------
// Trading rule: Long exit (On Bar Open)
//--------------------------------------------------------------------           
if ((LongExitSignal
   and Not LongEntrySignal)
   and (MarketPosition("Any", MagicNumber, "") is Long))
{
    // Action #1
    Close Full position for Symbol = Any and Magic Number = MagicNumber;

}

//--------------------------------------------------------------------
// Trading rule: Short exit (On Bar Open)
//--------------------------------------------------------------------           
if ((ShortExitSignal
   and Not ShortEntrySignal)
   and (MarketPosition("Any", MagicNumber, "") is Short))
{
    // Action #1
    Close Full position for Symbol = Any and Magic Number = MagicNumber;

}



Broker: 0