I am massively incompetent when it comes to coding and I am here for help. I keep missing out on trades in a particular strategy and want to see if automating it would make it easier. My filters for it are structure in higher time frame and an ema but I am happy to assess that myself. The entry conditions for a long, that I’d like someone to code for me, are:
- Last Candle – Negative body candle
- Current Candle – Positive body candle
- Close within top third or quarter of candle body
Entry
- Stop long order to trigger let’s say 5 points higher than the top of the current candle
- UK spread betting so per point rather than contracts
- Stop loss order let’s say 5 points under the current candle
- Extra options:
- Order good for x minutes (I think the broker allows that)
- The buy price must be minimum y points under the highest high of the last 10 ish candles. I don’t want to buy into new area.
- Max risked points (Stop entry minus stop loss) =z
I’d happily pay someone if available.
Thank you very much,
C
Here you have an example:
// Configurable parameters declaration
puntosEntrada = 5 // Points above the current candle to trigger the buy stop order
puntosStop = 5 // Points below the current candle for the stop loss
validacionMinutos = 10 // Duration of the order in minutes
distanciaMaxima = 10 // Minimum points below the highest high of the last 10 candles where the buy price should be
riesgoMaximo = 15 // Maximum risk points allowed (stop entry - stop loss)
ratioBeneficio = 2 // Ratio to calculate the take profit target (e.g., 2:1)
// Candle variables
cuerpo = abs(open - close) // Body size of the current candle
rango = High - Low // Range of the current candle
// Defining candle conditions
PreviousCandleNegative = Open[1] > Close[1] // Previous candle with a negative body
CurrentCandlePositive = Close > Open // Current candle with a positive body
// Close within the top third or quarter of the candle body
closeInUpperThird = Close > (High - (rango / 3))
closeInUpperQuarter = Close > (High - (rango / 4))
// Identification of the highest high of the last 10 candles
highestHighLast10 = HIGHEST[10](High)
y = 10 // Variable used as an example
// Entry conditions for a long position
IF PreviousCandleNegative AND CurrentCandlePositive THEN
IF (closeInUpperThird OR closeInUpperQuarter) THEN
// Calculate entry and stop levels
entryLevel = High + puntosEntrada * POINTSIZE
stopLevel = Low - puntosStop * POINTSIZE
riskPoints = entryLevel - stopLevel
// Calculate the take profit target
profitTarget = entryLevel + riskPoints * ratioBeneficio
// Check additional conditions
IF entryLevel < (highestHighLast10 - distanciaMaxima * POINTSIZE) AND riskPoints <= riesgoMaximo * POINTSIZE THEN
// Place buy stop order
BUY 1 contract AT entryLevel STOP
// Set stop loss
SET STOP price stopLevel
// Set take profit target
SET TARGET price profitTarget
ENDIF
ENDIF
ENDIF
Hello Catalin
On which instruments, timeframe do you plan to investigate this strategy ?
Do you have backtest results you could share ?
I am personally investigating future index tradings (small Nasdaq, Dow, CAC, DAX). Let us see if we have common interests.
Thanks
Hi, I dont have backtests the way algo traders seem to produce. I cant code an entry, I have no hope in hell to code market structure. I intend to use it on the major indices.
Not sure what you are saying above, but just to show that the code Ivan provided (3 posts above) does open and close trades, see attached.
Hi, I meant to say that what I asked for help with only covers they entry side of things. Getting in at retest of structure is what I believe gives it a chance to work and I have no hope to code that. So my plan is to set up alerts at levels that make sense and then set the algo so I dont have to waste hours waiting for an entry.
I dont have to waste hours waiting for an entry.
If with IG then you can set a Notification Alert to your phone when a trade is opened.
Re code for market structure … if you can state in plain english what you want your code to do then there are a few very kind ‘coding wizards’ on here who would code it for you.
Plain english specification in bullet points are good as easy to follow and makes for brief statements of requirements.