Tradestation 8 coding help

pecas

Member
Messages
75
Likes
6
Cheers,
I have a workspace with four charts running strategies.

In each strategy I have inputs to compute how many contracts I should trade.

It's easy math, there's an input named MaxRisk, one named BankRoll, and another named MarginRequired: I trade the number of contracts that fit my MaxRisk setting, but also the Margin Requirements related to my bankroll. So if risk settings say trade 10x, but I have the margin for 5, I trade 5.

Now the problem arises when two trades happen at the same time. I'm using my bankroll to trade a future, how to tell the strategy in the other chart that $ X are busy with another trade? I didn't find anything in EasyLanguage that refers to this; maybe there's something related to your account if you trade with Tradestation brokerage, but I don't, so that's useless.
 
Hi Pecas,

You can use Globalvariables to send information from one chart to another chart..
Post a PM to me if you have any difficulties...

Manigandan.
 
Hi Pecas,

No Need, Tradestation has its own Globalvariables.dll and its functions that can be used in Tradestation Easylanguage which was created by Tradestation users.

Thanks,
Manigandan.
 
OK, thanks a lot. I'm out for the weekend but will try this on Manday and be back at you with results.
 
I tried using GlobalVariables, but I can't verify my strategy... It's a strange error on this line:
Code:
	SetRtn1 = GVSetDouble(0,FreeMargin);
I get the following error: Grammar Error - Numerical expression expected here.
Like if "GVSetDouble(0,FreeMargin)" is not considered a number.
"FreeMargin" is a variable, and I copied the line from an example indicator that verifies correctly :?:


EDIT: forget about it... error was on line above..
 
Last edited:
Thanks a lot. I solved my problem with global Variables and recommended your post.
 
At what point does TS update the value of the global variables? At the beginning of a bar, at the close, or real-time? Be very careful. These high level languages are known to be based on a lot of conditions.
 
I have an indicator that plots the value of global variables, just to stay safe.
The option "update the value intra-bar" is on.
It's my strategy that sets the value of the global variable, so all depends on the "Calculation" options. If I allow the strategy to calculate only once per bar, then GVs will update once per bar; if I allow tick by tick calculation, they will be updated tick by tick.
At the moment, once per bar suits my strategy.
 
Top