Strategy is mysteriously crashing TradeStation - futures io
futures io



Strategy is mysteriously crashing TradeStation


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,202 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Strategy is mysteriously crashing TradeStation

(login for full post details)
  #1 (permalink)
EzPz
Puyallup
 
 
Posts: 7 since Oct 2020
Thanks: 2 given, 4 received

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.

 
Code
// Long Entry
If MarketPosition = 0 And MagicHappens() Then
	Buy ("Entry_L") PositionSize Contracts Next Bar Open;

// Stop and Target
If MarketPosition <> 0 Then
Begin
	SetStopPosition;
	SetPercentTrailing(PercentTrailFloor, PercentTrailPerc);
	Setstoploss(StopLoss);
End;

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.

 
Code
// Long Entry
If MarketPosition = 0 And MagicHappens() Then
	Buy ("Entry_L") PositionSize Contracts Next Bar Open;


// Stop 
If MarketPosition <> 0 Then
Begin
	SetStopPosition;
	Setstoploss(StopLoss);
End;

// Target
If MarketPosition <> 0 Then
Begin
	SetStopPosition;
	SetPercentTrailing(PercentTrailFloor, PercentTrailPerc);
End;

Reply With Quote

Can you help answer these questions
from other members on futures io?
Market on Close data within IB
Platforms and Indicators
How do I create Strategy with the Second Entry indicator
NinjaTrader
Big Mo Indicator for NT8
NinjaTrader
in depth understanding of last, bid, and ask volume in c …
NinjaTrader
NT8 Order Management Strategy
The Elite Circle
 
 
(login for full post details)
  #2 (permalink)
 ShadowFox 
CO/USA
 
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
 
ShadowFox's Avatar
 
Posts: 116 since Jun 2020
Thanks: 69 given, 156 received

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.

 
Code
// Long Entry
If MarketPosition = 0 And MagicHappens() Then
	Buy ("Entry_L") PositionSize Contracts Next Bar Open;

SetStopPosition;
SetPercentTrailing(PercentTrailFloor, PercentTrailPerc);
Setstoploss(StopLoss);
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()".

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #3 (permalink)
EzPz
Puyallup
 
 
Posts: 7 since Oct 2020
Thanks: 2 given, 4 received



ShadowFox View Post
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.

 
Code
// Long Entry
If MarketPosition = 0 And MagicHappens() Then
	Buy ("Entry_L") PositionSize Contracts Next Bar Open;

SetStopPosition;
SetPercentTrailing(PercentTrailFloor, PercentTrailPerc);
Setstoploss(StopLoss);
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.

Thanks,
-Ez

Reply With Quote
 
(login for full post details)
  #4 (permalink)
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
 
syswizard's Avatar
 
Posts: 344 since Jan 2019
Thanks: 20 given, 138 received

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.

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Strategy is mysteriously crashing TradeStation


Last Updated on April 20, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2023 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts