Login Page - Create Account

Support Board


Date/Time: Sat, 27 Apr 2024 03:46:35 +0000



Please, a clarification on the sc.SetDefaults area

View Count: 825

[2019-06-13 15:18:45]
User932967 - Posts: 18
In Metatrader there is an area where to insert the code that is started only once immediately after the launch of the program:

void OnInit () {}

where it is possible to insert some code to calculate the value of some global variables useful in the other routines of the program.
A routine example can be the following:

double ticktemp = sc.TickSize;
if (tickDim == 0) { tick = ticktemp; }
else { if (tickDim<ticktemp) tick = ticktemp; else tick = tickDim; }

- tickDim is an input value from the user.
- tick is the persistent variable to be calculated at the launch of the program used to define stop loss and take profit.

Is the sc.SetDefaults area similar to the OnInit area?

Reading the various code examples inserted in Sierra, I can't find one that answers to my question. In the example I have a sequence like this:
1) sc.Input area
2) sc.SetDefaults area where, however, we define the values of the inputs..
3) definition of persistent variables

with this code sequence I believe that the calculation routine described above could not work properly if inserted in sc.SetDefaults..
Date Time Of Last Edit: 2019-06-13 15:20:00
[2019-06-14 11:14:59]
Sierra Chart Engineering - Posts: 104368

Is the sc.SetDefaults area similar to the OnInit area?
Yes you should be able to use it for the same purpose but you can implement your own section in the code for this. Just simply use a persistent variable:
sc.GetPersistentInt()

When it is initially false, do your initialization and then set it to true and then no longer do the initialization.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-06-14 12:35:10]
User932967 - Posts: 18
Thanks

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account