Login Page - Create Account

Support Board


Date/Time: Wed, 08 May 2024 21:19:16 +0000



Post From: Please, a clarification on the sc.SetDefaults area

[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