Hi everyone! I need some help, please .. I would like to make a backtest code and a proorder with the following parameters:
Long operations:
– The closing of yesterday has to be higher than the opening of yesterday
– The closure before yesterday has to be less than the opening before yesterday
– The SMA 14 has to be on the rise
– The purchase order is executed when the price touch the maximum daily yesterday.
– Trailling stop 10%
Short operations:
– The closing of yesterday has to be less than the opening of yesterday
– The closure before yesterday has to be higher than the opening before yesterday.
– The SMA must be downward
– The sell order is executed when the price touches the daily minimum today yesterday
– Trailing stop 10%
Sorry about my englsih and thanks a lot in advance for your help!!
Nuria
Hi, girl. Yes, I’m sorry to say that your English is bad indeed. Let me rewrite the post for you in advanced English:
Hi everyone! I need some help, please: How can I learn to program this very easy to code strategy?
I’m sure you’ll then help me with all my beginner’s errors. Thanks in advance!!
‘Lazy’ Nuria
Better?
Hi Nuria, from where did you get this strategy description? Is it yours?
It is true that this strategy is easy to code, did you even try with the assistant?
Titikaka, thanks for your help. Sorry if I’m not in your level, I,m a begginer.
Have a nice trading.
Hi Nicolas!
Thanks for your patience! I get this strategy after tried on MT4, after long time, whit some mix of strategies from some books. I do that in Indices, TF: 1D, and it works fine, but I want to improve a little bit the strategy with Prorealtime. I tried to do it with the assistant but I can’t get how to put the bar of yesterday and befeore yesterday, and how to put conditioned. Also I don’t know how to put that the SMA 14 in green or red, like I have drawn on my graphic.
I will try until I get it! I would be grateful if you can help me.
Thanks a lot!!!
Nuria
This code is for long side only, I think you’ll have no difficulty to adapt it for short side by yourself:
defparam cumulateorders = false
avg = average[14]
long1 = close>open
long2 = close[1]<open[1]
long3 = avg>avg[1]
if long1 and long2 and long3 then
BUY 1 SHARE AT high STOP
endif
SET STOP %TRAILING 10
The breakout of the yesterday’s high last only 1 bar.
Nicolas, thank you very much! I was tried to do the code for long side with the assistant to compare with your code, and I get it some different…
DEFPARAM CumulateOrders = False
indicator1 = Average[14](close)
indicator2 = Average[14](close)
c1 = (indicator1 > indicator2[1])
c2 = (DClose(0) > DOpen(0))
c3 = (DClose(1) < DOpen(1))
indicator3 = close
c4 = (indicator3 = DHigh(0))
IF c1 AND c2 AND c3 AND c4 THEN
BUY 1 SHARES AT MARKET
ENDIF
SET STOP %LOSS 10
Do you know if there is any lessons about the basics of the assistant?
Thanks a lot!!
Nuria
>> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
The result code from the assistant is pretty much the same, you use here the daily OHLC instead of the current timeframe ones. About the breakout (buy level) of the daily high on lines 10 and 11 you should use the crosses over instruction instead. Here you are testing if the current close is exactly the same as the daily high which is almost impossible to be true.
There is a video about how to create an automated trading strategy with the assistant in the blog.
Thakn you very much Nicolas!! Have a nice day and a nice trading..
Glad to see you are not lazy Nuria but fighting Nuria after all. That’s the way and the only way.
Good luck with your trading.