MLParticipant
Average
Hi everybody,
I have a quick question for you. I just built a simple Trading System. I would like to put in code something like “when this condition happen buy two (or three) bars after the signal happened”.
Would it be possible?
Thanks a lot in advance
ML
Hi, you can compare the BARINDEX between the current one and the one when your signal occurred.
MLParticipant
Average
Hi Nicolas!
Can you explain better?
Let say I have something like:
xxx=golong+goshort
if xxx=1 then
buy 1 contracts at market nextbaropen
elsif xxx=-1 then
sellshort 1 contracts at market nextbaropen
endif
My idea would be to write something like “buy 1 contracts at market nexttwobaropen” but I know it does not exist!
How can I use the BARINDEX comand?
Thanks a lot in advance for your reply!
ML
nextbaropen is depreciated, it is not used anymore in the PRT language.
You can save the barindex when your signal occur and then compare its value with the current barindex one. Of course your ‘golong’ signal should occur only once in the past, otherwise the ‘signalbar’ variable would be constantly renewed with the current barindex.
xxx = golong
if xxx then
signalbar = barindex
endif
if barindex-xxx=2 then
buy 1 lot at market
endif
Please take the time to understand before asking your next question 🙂