Set a specific time to exit from all positions
Author: aadantas
Creation Date: 8/8/2020 12:43 AM
profile picture

aadantas

#1
Hello,

I tried, but I confess I'm not uderstanding why I´m being unsuccessfull yet. So, please, could you teach me some way, through the rules wizard, that I could set a specific time inside the day so that I exit from all positions?

Thank you for your attencion,
Regards,

Alexandre
profile picture

Eugene

#2
Hi,

There's a rule called "Intraday Rule: Time is later (earlier) than HHmm" under Date/Time conditions which should get the job done.
profile picture

DPGfinancas

#3
Hi Eugene, I have the same question.

This rule is not working for me correctly .I keep seeing trades before 10am.

Below is my script, I will be very grateful if you can help me!!


CODE:
Please log in to see this code.
profile picture

Cone

#4
QUOTE:
...that I could set a specific time inside the day so that I exit from all positions?

You applied the time condition to the entry logic.
If you're using the Strategy Builder, add a SellAtMarket order and move the time condition to it.

As for trades bought or shorted before 10am, I'd have to say that it's "impossible" using the code above.
profile picture

DPGfinancas

#5
Thank you Cone!
If I understand correctly, I can't use this rule to buy or shortl after 10am, in this case, the second bar of the day?
profile picture

Eugene

#6
Diego, I think there's a misunderstanding. Robert responded to Alexandre's (topic starter) post looking at your code. But despite you saying "I have the same question", that's incorrect. In fact you're trying to enter after 10:00am whereas topic starter's task was about exiting at a given time.

QUOTE:
I keep seeing trades before 10am.

Right, if a signal took place at the last bar of the day (e.g. 11:00pm for an instrument that trades round the clock) you will see a trade on the next bar (e.g. 12:00am next day). Formally it's correct. Anyway, you should add another condition preventing the entry after some time e.g.

CODE:
Please log in to see this code.
profile picture

Cone

#7
QUOTE:
Robert responded to Alexandre's (topic starter) post looking at your code.
Whoops!
profile picture

DPGfinancas

#8
Eugene,
sorry for the misunderstanding and thanks for your help!
I was imagining that it would be related to the closing of the previous day.

I will add this code!
profile picture

Eugene

#9
Don't worry about it. You're welcome.
QUOTE:
I will add this code!

In case it wasn't obvious from my reply, you can also add a second "Intraday Rule: Time is later (earlier) than HHmm" condition - one for "later" (than 10:00) and the other for "earlier" (than 16:00, 23:00 or whatever).
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).