Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I have a strategy that I am testing in multiple different markets to see which market it works best in. Unfortunately after about 6 - 12 hours I get a message from TradeStation that it needs to shut down. One of the pop up windows at this time informs me that an invalid argument was supplied. I will include a slightly modified version of the code because I suspect that I must be doing something wrong even though the code compiles okay.
Does anyone know what I am doing wrong? I suspect it might have something to do with the way that I am exiting the trade.
Some hours later...
So I thought that I might need to call SetStopPosition for each Set statement so I modified the code thusly and it is still failing as before. Please see below.
Can you help answer these questions from other members on NexusFi?
You actually don't need to check for a marketposition before setting your stop conditions that you have. You can just do the below without the if statement.
No need to SetStopPosition before each statement though.
You can also use SetProfitTarget if you do not like the performance of your Percent trail. Or use the percent trail as a way to lock profits if your target is not reached.
I don't see anything in the original post though that should throw an error. My guess is something funky is happening in "MagicHappens()".
I took the MagicHappens() function out and just made it a simple closing price crossover, because I thought the same thing but it is still failing. I will try all your recommendations and post the entire code here if that does not solve it.
Try replacing SETSTOPPOSITION to SETSTOPCONTRACT......just for testing purposes.
Also, you should be tracing the code using the PRINT statement.
Send the Traces to a file.