Hi,
I am looking for a code to close all open positions (no matter of the P&L) each day at a specified time.
Any help is highly apprecoated.
Rouven
Size:
Color:
Hi Rouven,
Here's a quick example that requires
Community.Components. Run it on 5-minute data.
In a single-position strategy:
CODE:
Please log in to see this code.
In multi-position strategy:
CODE:
Please log in to see this code.
Size:
Color:
Thanks very much Eugene
Size:
Color:
Works very well when leaving
CODE:
Please log in to see this code.
out. otherwise CS0136 for ASCII with my local time
when using IQFeed (trading hours are labelled 02.00-1600 on the chat facing a Run time error. No error when using off trading hours, just in active trading hours.
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
otherwise CS0136 for ASCII with my local time
That's expected: starting at bar #1 is only good for my example. To avoid an index out of bounds error (IOOB) in real code, you have to:
* use GetTradingLoopStartBar,
* care about indicators that don't have an input parameter named "period" (because GetTradingLoopStartBar is unable to sense such indicators),
* not exceed the largest indicator period by accessing a value N bars ago (e.g. suppose your largest indicator period is 5 bars but you're evaluating its value 20 bars ago),
* and use FirstActualBar if necessary.
Size:
Color:
Call me a Muppet, but I can’t get it up and running, still the same issue.
Grateful for any help in the forum.
Size:
Color:
Are you sure that the fast MA is 28-period and the slow one is 14-period? Otherwise feel free to unroll my change. Hope this helps:
CODE:
Please log in to see this code.
Size:
Color:
Thank you very much for all you time and your help!
Size:
Color: