Hi Nicolas, in order of your recommendation I´m writing here what I need to do for using your Perfect Trend indicator as an automatic trader. First of all, I want to operate in DAX Full Future in 1 minute, and I´ve made a list of paramethers that I wish it would have, for example:
- Open only longs
- Open longs when the blue dot gets on
- Limit: 5 points
- Stop: 5 points
- Close the operation if a red dot gets on
- Get a minimum of 20 points daily and a máximum of 24
- Maximum of operations daily: 150
- Schedule: From 8:00 to 17:00
Thank you very much.
Eduardo Siverio
When you speak English, it is obvious to open a thread in the English forum .. just saying it ..
This is the code of the strategy you asked for. I omit the MaxDaily profit which I don’t think it is useful in this case, make your own tests and tell us how it goes..
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
defparam flatbefore = 080000
defparam flatafter = 170000
// --- settings
SlowLength = 7 // Slow length
SlowPipDisplace = 0 // Slow pip displace
FastLength = 3 // Fast length
FastPipDisplace = 0 // Fast pip displace
MinDailyProfit=20 //Max daily loss allowed (in points)
// --- end of settings
thigh1 = Highest[SlowLength](high)+ SlowPipDisplace*pointsize
tlow1 = Lowest[SlowLength](low)- SlowPipDisplace*pointsize
thigh2 = Highest[FastLength](high)+ FastPipDisplace*pointsize
tlow2 = Lowest[FastLength](low)- FastPipDisplace*pointsize
if barindex>2 then
if Close>line1[1] then
line1 = tlow1
else
line1 = thigh1
endif
if Close>line2[1] then
line2 = tlow2
else
line2 = thigh2
endif
endif
if (Close[0]<line1[0] and Close[0]<line2[0]) then
trend = 1
endif
if (Close[0]>line1[0] and Close[0]>line2[0]) then
trend = -1
endif
if (line1[0]>line2[0] or trend[0] = 1) then
trena = 1
endif
if (line1[0]<line2[0] or trend[0] = -1) then
trena = -1
endif
//----
// first time we launch the code, the trading is allowed
once TradeAllowed=1
if intradaybarindex=0 then
count=0
MyProfit=STRATEGYPROFIT
TradeAllowed=1
endif
// test if the strategyprofit of the day is currently above the daily profit allowed
If StrategyProfit>=MyProfit+(MinDailyProfit*POINTVALUE) then
TradeAllowed=0
endif
if TradeAllowed and trena<>trena[1] and trend=-1 and not onmarket and count<150 then
buy 1 contract at market
endif
if longonmarket and trend=1 then
sell at market
endif
if longonmarket and tradeindex<>lastindex then
count=count+1
lastindex=tradeindex
endif
SET STOP PLOSS 5
SET TARGET PPROFIT 5
Muchas gracias Nicolas y mil disculpas por lo del inglés, desconocía que estaba en el foro en español.
Una pregunta, me aparece un error de sintaxis en la fila 5, qué debo hacer para corregirlo?
Gracias
The topic is now in the English forum, do not speak Spanish please. There is no syntax error in the code, please copy/paste it once more.
Sorry for the spanish.
I´m attaching the error the system gives me, I´ve tryed several times copying and pasteing the program but I can´t validate it. Also I´ve erased the symbol that is giving me the “error” and the thing became worse. When I downloaded your Perfect trend indicator was from an ITF file, I don´t know if it´s posible to have this code like an ITF file too to import it directly and avoid the copy/paste. Please excuse my ignorance in this subject.
Thank you
Eduardo Siverio
Totally odd, what is the “symbol” you erased that give you the error? There is no character at line 5!
Please try to delete the “añadir” variable that still exist (certainly from a previous code) in the optimisation settings.. Variable name can’t have accent, this is what may cause the problem here.
Well, I can´t see the symbol, but the space is being occuped by a ” ” (I´ve copied and pasted it, is between question marks), and it appears in lines 5, 13, 18, 31, 44, 53, 58 and 69 too. I erased everything and paste only the code, but it remains the “sintaxis error”. In the attachment you can see what it looks like.
I think the way you copy/paste code from here is wrong. Are you on PC or MAC or LINUX? What is your web browser?
Please find below the instructions on how to copy/paste code from this website.
Got it!
Thank you, on monday i`ll try it in demo.
Hi Nicolas,
I adjusted the limit and the stop in the backtest, I put Limit 6 and stop 8. The result in a walk forward was terrible. My idea was to earn 50 points per week, and between monday and wednesday I earned 28.5 points (not bad) but between thursday and friday I lost 51 points. The result is -22.5/week. My idea doesn´t works. So, If you have some recomendation to improve the code (or another code) I´ll be glad to read about it. Thank you for your time.
Eduardo
Why not backtesting it and try to improve the strategy? Testing a strategy only during one week should not guarantee if it is worth nothing (or if it’s worth one million dollars too .. ).
thank you again, I´ll try to improve it.
Hi Nicolas,
It´s posible to add a maximum daily loss to the code and a trailing stop of 1 point that activates when the value gets the target profit?
Thank you
Eduardo
A trailing stop of “only” 1 point should not work, it depends mainly of the allowed stop distance from price from your broker (and it’s different for every single security).
About a daily loss trigger, you have something already available in this blog post: https://www.prorealcode.com/blog/learning/max-profit-loss-day-trading-strategy/