This strategy is a Gold Scalping System designed to trade the NYSE breakout at the close of the second 10-minute candle after the market opens – this is the decision bar.
The strategy uses a breakout technique, entering long when the price breaks above the high of the second candle or short when it breaks below the low, with a 0.5-point entry buffer to avoid false breakouts. The system utilizes a fixed stop loss of 2.5 points and a take profit of 2 points. The strategy is limited to 1 trade per day,
could someone help code this as Ive had issues with it so i can test it on probacktest
.
JSParticipant
Senior
Hi,
Try this one:
// === Parameters ===
once entryBuffer = 0.5
once stopLoss = 2.5
once takeProfit = 2.0
// === NYSE time (adjust if needed) ===
// Make sure your timezone is set correctly! NYSE opens at 15:30 CET
marketOpenTime = 153000
decisionCandleEnd = 155000
// === Capture second 10-min candle (decision bar) ===
if OpenTime = decisionCandleEnd then
decisionHigh = high
decisionLow = low
entryLong = decisionHigh + entryBuffer
entryShort = decisionLow - entryBuffer
tradeDone = 0 // reset trade flag
endif
// === Trade Entry (1 trade per day) ===
if not onmarket and tradeDone = 0 then
// Long breakout
if high > entryLong then
buy 1 contract at market
sl = close - stopLoss
tp = close + takeProfit
tradeDone = 1
endif
// Short breakout
if low < entryShort then
sellshort 1 contract at market
sl = close + stopLoss
tp = close - takeProfit
tradeDone = 1
endif
endif
// === Trade Management ===
if longonmarket then
// Take profit
if close >= tp then
sell at market
endif
// Stop loss
if close <= sl then
sell at market
endif
endif
if shortonmarket then
// Take profit
if close <= tp then
exitshort at market
endif
// Stop loss
if close >= sl then
exitshort at market
endif
endif
GraphOnPrice DecisionHigh as "High"
GraphOnPrice DecisionLow as "Low"