Issued when using Fictitious Execution and all types of orders, except for "By Market" orders.
For example: System.NotImplementedException: It doesn't possible. at TSLab.ScriptEngine.PositionsList.OpenIfGreater
Fictitious execution and conditional order are used, Open if greater. Fictitious execution works only with "By Market" orders. Please use them.
TSLab recognizes string interpolation in code starting from version 2.1. Doesn't work in earlier versions, the script will throw an error, so use string formatting.
An example of string interpolation:
A similar entry through formatting:
The ctx.Runtime.LastRecalcReasons property contains a list of the script recalculation reasons. There may be several of them.
An example of how to get the reason for the recalculation of the script (displayed in the log):
An example of how to get the event of opening a position (displayed in the log):
In the agent settings, the Events -> Position opened checkbox must be enabled, then the script will be recalculated when a position is opened. All possible events are listed in the EventKind enum.
Some brokers do not broadcast information about the price step when the quotes are updated (UpdateQuote Event)
Accordingly, in the API, for example:
it is impossible to pull out the price step from ITInvest. This line will work for other brokers. FinInfo.StepPrice has the same properties as FinInfo.BuyDeposit, BuyDeposit will work, StepPrice is not, the broker simply does not send it.
It is easy to check what exactly the broker sends in quotes using the Quotes window. View - Quotes. Select the instruments of interest by right-clicking. If there is no data in the table, then there will be no data in the API.
Close, Open, High, Low via Contex.GetData? or are the symbol.GetClosePrices (context) methods already cached?
===
Does not matter. Within the GetClosePrices, GetOpenPrices, ... methods there is a call to context.GetDat
There is no communication via COM. You can write scripts in api c #, agents have access to their deals.
The ISecurity API has methods:
IReadOnlyList GetBuyQueue (int barNum);
IReadOnlyList GetSellQueue (int barNum);
How UpdateQueueData () works
This function resets the cache and forces the order manager data to be re-requested. This is done - to reduce the load. It turns out that in order to get the latest information, you need to make a call to UpdateQueueData before each call to GetBuyQueue / GetSellQueue
The order manager is “fixed” at the time of recount to ensure that the “mold” of the order manager (both parts of it) is taken at the moment the recount begins.
In order to update the order manager during the recount and get a new impression, this method was made. Not related to performance.
Method for forced recalculation of the script:
IContext.Runtime.Recalc (string recalcReason, IDataSourceSecurity dataSourceSecurity, bool inAnyCase = fals)
recalcReason - recalculation reason, any string.
dataSourceSecurity - the source from which the recalculation is started. You can pass null.
inAnyCase - perform recalculation anyway. If false is specified, then recalculation will be performed only if the current recalculation is completed (used in metronome cubes). If true is specified, then recalculation will be performed immediately after the current recalculation.
Call example:
For example, the current reason for recalculating the script is read, if the script is not launched through the Recalc method, then Recalc is launched, waits for 5 seconds and ends. After completion, a new recalculation is started, it will indicate that the current recalculation reason is "MyRecalc" and will not be called Recalc again.
"I save the variable to the cache:
the next time the script is recalculated, I load:
And I always get a message stating that there is nothing in the cache for this key. "
===
You need to use the NotClearableContainer class and store the objects in the cache, not the value types, because the boxing and unboxing operations are obtained.
In the code, you can specify slippage when working with a position:
Set stop with slippage of 100:
Place a take with a slippage of 100:
Important: One slippage value must be used in the script. For example, set a stop (CloseAtStop) and a take (CloseAtProfit). In both cases, you must pass one slip value to these methods. If they are different, then the latter will be applied for both applications. If slippage is not specified in the code, it will be applied from the agent settings.
In order to view the .cs file from the program code generator, you need to:
Open in the program: File -> Program Settings -> Script Optimization -> Script debugging
Create a script and compile it. The .cs file will be available in the temp folder. It is not difficult to get into it from the program. Tools -> Log Folder -> Go up one level higher, on the same level with the logs folder, temp folder. An example of creating a script in the visual program editor and viewing the C # (CS file) of this script from the code generator.
An encrypted container can contain a dll library inside itself and the script will work with it. But one condition, the script should not call statics of the field or methods from the library.
Two double variables cannot be compared. You can see about this on the Internet.
==================================
Hello. Faced a problem in the API. The algorithm should check the relevance of the order price and cancel it if the price is not up to date. Here's a real-world example.
The price of an active order in real time is 1332.8
That is, for some reason a problem arises when the subtraction and addition of decimal fractions occurs - after that the two variables are not compared correctly
If this code is executed, everything works correctly - the application is not canceled, a new one is not placed
If this code is executed, the order is ALWAYS canceled, and then EXACTLY the same with the same price is placed
At the same time, if the variable is made in this way, then everything works correctly.
Hello dear developers!
I ask you to explain to me the purpose of some parameters in the "HandlerParameter" Attribute:
1) In the "Third overload" of the "HandlerParameter" attribute, there are parameters one after another: bool isShown, string def, [string Default] and so on.
The explanation for "string def" says: "Default value". The explanation for "[string Default]" says: "The default parameter value is a string."
I have a question: If these are both parameters "by default", then what are the differences between them and what is each of them for?
2) "[string Editor]" is the "Parameter Editor".
Question: What does the "Parameter editor" mean, what is the editing for, where the editing takes place, maybe it has something to do with optimization, that is, is it like "OptimProperty"?
3) What are [string EditorMax] and [string EditorMin] for, as well as [string Max] and [string Min]? I suppose that one of these pairs sets the framework in which the optimization of the parameter should take place, but why is the second pair needed then?
4) [string Step] - "The parameter step for the value is a string". Do I understand correctly that this is "Step of parameter change when using Optimization"?
5) Parameter [bool isCalculable] - I assume that the correct translation is "Calculated". What does "Calculated? What is this parameter for?"
=========
According to the documentation, there is no such overload http://files.tslab.ru/docs/2.0/en/api/class_t_s_lab_1_1_script_1_1_handlers_1_1_handler_parameter.html. Inside the constructor HandlerParameter (bool isShown, string def) def is assigned to Default Attributes in C #. In particular, the difference between positional and named parameters. The syntax in attribute declarations allows positional and named parameters to be specified at the same time, even though they refer to the same class member. What Visual Studio shows in square brackets are named parameters.
"[string Editor]" is used to set a visual editor for a property other than the default. This also requires support within the program, so users cannot use this attribute at this time.
[string EditorMax] and [string EditorMin] are used to validate input values.
[string Max] and [string Min] and [string Step] Min, Max and Step on the Optimization tab
[bool isCalculable] this means that the parameter can participate in optimization, ie. appear on the Optimization tab.