Slider

Posted By: kujo

Slider - 01/31/18 23:02

Manual says on the Slider's page the following:
Quote:
The sliders jump to their default positions (pos parameter) when the script is started the first time, or when [Script], [Asset], or [Edit] was clicked. Otherwise the sliders keep their previous position. For testing a script with a certain slider position, click [Test], wait until the sliders appear, then click [Stop], put the sliders to the desired position and click [Test] again. In [Trade] mode the sliders are stored in the .trd file and thus always 'remember' their last position.


It seems that this part isn't true anymore:
Quote:
or when [Script], [Asset], or [Edit] was clicked



This part is a bit inaccurate:
Quote:
For testing a script with a certain slider position, click [Test], wait until the sliders appear, then click [Stop], put the sliders to the desired position and click [Test] again.

It isn't enough to simply wait until the sliders appear. One should wait until the INITRUN is over and "Test: <script name>" message appears.

When it comes to the Trade mode, the logic is different and .trd file is used as mentioned in the manual. But what happens during the first run of a strategy when there is no trd file? According to my observations, when running a script for the first time in the Trade mode a desired slider position could be set using 2 options:
  • 1st option: Start Test. Wait until INITRUN is over and "Test: ..." message is shown. Stop it. Set the slider. Then Trade a script. The slider won't be overwritten by the default value.
  • 2nd option. Run a script with the default slider in the Trade mode. Simply change the slider while running in the Trade mode.
Posted By: jcl

Re: Slider - 02/01/18 10:27

You can move a slider as soon as it appears. This happens in the INITRUN when the slider name is assigned.
Posted By: kujo

Re: Slider - 02/01/18 11:14

Quote:
You can move a slider as soon as it appears.

Indeed, if you move it during run without hitting Stop. However, if you click Stop it's a different story. See below


Quote:
For testing a script with a certain slider position, click [Test], wait until the sliders appear, then click [Stop], put the sliders to the desired position and click [Test] again.


I've tried this with my script and logged every step. It doesn't work if I click Stop immediately after the slider appear. I change the slider but after I reTest a script the slider returns back. Above mentioned condition isn't enough. One should wait a bit longer and then hit Stop.
Posted By: kujo

Re: Slider - 02/06/18 16:20

Aside from above-mentioned there is one more question
Quote:
If the script needs to be recompiled, or if it contains any global or static variables that must be reset, click [Edit] before [Test]. This also resets the sliders to their default values. Otherwise the static and global variables and the sliders keep their settings from the previous test run.


Clicking Edit doesn't work as stated. So, what's the legit method to reset sliders and variables now? Should I click Edit and then Run in N++ to start a new instance of Zorro?
Posted By: jcl

Re: Slider - 02/07/18 10:53

To recompile and reset sliders and variables, click [Edit], then [Test]. Or click on the script scrollbox and select the script again. What did not work?
Posted By: kujo

Re: Slider - 02/07/18 15:48

Originally Posted By: jcl
To recompile and reset sliders and variables, click [Edit], then [Test]. Or click on the script scrollbox and select the script again. What did not work?


Oh, shoot! It does work. Sorry for confusion!

The only thing that doesn't work is:
Quote:
For testing a script with a certain slider position, click [Test], wait until the slider names appear, then click [Stop], put the sliders to the desired position and click [Test] again.


Try this:
- Start Zorro
- Select Z3
- Click Test and immediately after the sliders names appear click Stop
- Change Capital to 2100
- Click Test
- Capital is back to 2000

I just want to say that it's not enough to wait until sliders names appear, you should wait a little bit longer. That's it laugh
Posted By: jcl

Re: Slider - 02/07/18 15:57

Ah, ok. I'll check where this additional little bit time comes from. Possibly still some initialization, such as asset loading.
Posted By: fsgi

Re: Slider - 05/11/20 16:45

"Blast from the past" here.

Thank you for the nice discussion and...

Is there a way (any one!) for REALLY resetting a slider to a programatically chosen "position" (value) at script start-up, without using the value that is left there from the last run of the same script?

Thank you for the help and the patience.
Posted By: jcl

Re: Slider - 05/12/20 09:37

The sliders are reset to default when the script is changed or "Edit" is clicked. Otherwise call slider(N,Pos) to set them to a defined position.
Posted By: fsgi

Re: Slider - 05/12/20 15:55

Dear jcl,

this seems not to work as expected.

If I for instance code something like this:
Code
void main()
{
	slider(1, 0, 0, 100, "Test");
	slider(1, 0); //it should be useless
	printf("\nSlider value: %i", slider(1));
	int slider_output = 0;
	int count = 0;
	while(slider_output == 0)
	{
		if(count % 100 == 0)
		{
			printf("\n### Change value of slider 1 ###");
		}
		wait(1000);
		slider_output = slider(1);
		count++;
	}
	printf("\nnow slider has value: %i", slider_output);
	quit();
}


... when I run it , it produces a nice output:
Code
Slider value: 0
### Change value of slider 1 ###
now slider has value: 3
Quit


But then, as soon as I re-run the script without recompiling/shutting down Zorro/changing scritp, without touching ANYTHING (e.g. not shifting the slider back in the GUI), I still obtain

Code
Slider value: 0
### Change value of slider 1 ###
now slider has value: 3
Quit


...meaning that the GUI "fixed" slider is not reset programmatically and that it overwrites (or immediately changes back the programmatically-set slider value) to its position...

This was what I meant.
Posted By: danatrader

Re: Slider - 05/22/20 15:54

Try saving the slider position:

SaveMode = SV_SLIDERS+SV_ALGOVARS+SV_TRADES+SV_STATS+SV_BACKUP;
Posted By: Spirit

Re: Slider - 05/23/20 08:26

What should the saving do? He sets the slider to 0 and so it is at 0, where is the problem?
© 2024 lite-C Forums