.rld command after 2 minutes from the firts daily bar in IOB script  [SOLVED]

Questions about MultiCharts and user contributed studies.
auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

.rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 27 Mar 2017

Hi,

I tried to search in the wiki and in the older posts but I am still a little bit confused on this matter I am going to depict.

My Time Frame = 5 minutes,
my signal has IOB enabled.

I would like to reload automatically the chart by the ".rld" command after 2 minutes from the beginning of the daily session every day and after that to allow normally my entries from the second "5-minutes" bar (9:10).

Using 5 minutes resolution, the first bar is 9:05, the second 9:20 and so on.
May I use this code? and in particular the line "Time=902"?

Code: Select all

if Time = 902 then CommandLine(".rld");
if time >= 910 and time <920 then buy .....
with IOB enabled, what happens? If it is not possible this way and I decide to replace 9:03 with 9:05, so... what will happen?
For example, if there will be 100 ticks in the first bar 9:05, will the .rld command be executed 100 times?

Thanks
Last edited by auato on 28 Mar 2017, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby TJ » 27 Mar 2017

Look up the keyword:

CurrentTime

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby TJ » 27 Mar 2017

Please read the IOG definition carefully.


As the name implies, it is for ORDER GENERATION only.

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 27 Mar 2017

Thank you @TJ. You are all the time so kind and available. So I got it right about IOG. It is only for order generaction so this means I have to replace only "time" keyword with "currenttime" in my code as below:

Code: Select all

if CurrentTime = 902 then CommandLine(".rld");
if time >= 910 and time <920 then buy .....
Last edited by auato on 28 Mar 2017, edited 1 time in total.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby JoshM » 28 Mar 2017

Please read the IOG definition carefully.


As the name implies, it is for ORDER GENERATION only.
That's not true; see how signals are calculated.

When intra-bar order generation is enabled, the signal calculates with every incoming real-time tick (as opposed to only calculate on bar close). Those tick-by-tick calculations can be used for submitting orders, but a signal can also do anything else during those calculations.

So intra-bar order generation is not for order generation only, but more a way to keep a script more responsive by calculating more often.

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 28 Mar 2017

Thanks @JoshM.

Anyway the code doesn't work. If I use the code above with Currenttime or CurrentTime_s nothing happens and if I replace CurrentTime with Time or Time_s with the the timestamp of the bars I don't know why my chart starts to reload all the time in a loop even if the time for current bar is completely different.

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 28 Mar 2017

update:
I think I understood the solution:
if the code above doesn't work, please extend the time window. Maybe with IOG it updates every tick... that's why it is better to have a larger time window in which there are more possibilities to have new ticks.

So, you can use this alternative and working code:

Code: Select all

if CurrentTime_s >090200 and CurrentTime_s < 090230 then begin CommandLine(".rld");
End;
if time >= 910 and time <920 then buy .....
Last edited by auato on 28 Mar 2017, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby TJ » 28 Mar 2017

Also look up the keyword

ONCE

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 28 Mar 2017

Great suggestion! With "Once" I can avoid the loop.
Thanks again

Code: Select all

once (CurrentTime_s >090200 and CurrentTime_s < 090230) begin CommandLine(".rld");
End;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby TJ » 28 Mar 2017

Great suggestion! With "Once" I can avoid the loop.
Thanks again

You are welcome.

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 03 Apr 2017

There is something doesn't work for me. Also triying with ONCE command in one minute of time window (from 9:03 to 09:04) I notice a continuous loop of the .rld command. As I have IOB enabled, I guess it refreshes every tick. As I would like to avoid this useless loop, I tried with a cycle composed by two nested IF .... but my loop persist during that minute :?

Code: Select all

vars: RLD(0);
IF RLD=0 then Begin
IF currenttime_s>=090300 and currenttime_s<=090400 then begin
CommandLine(".rld int =1 day");
CommandLine(".at_toggle");
RLD=1;
end;
end;
please, could you help me to find where I am wrong?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby TJ » 03 Apr 2017

Try this:

Code: Select all


IF currenttime_s>=090300 then begin
ONCE begin
CommandLine(".rld int =1 day");
CommandLine(".at_toggle");
end;
end;

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 04 Apr 2017

Thanks @TJ... with your code I have a continuous loop.


For Currenttime_s() unless the help/wiki states :
Use CurrentTime to get the computer's current time with minutes precision.
I didnt understand if currentime_s() really reads the local time of my computer or it refreshes at every tick...
because sometimes, when the market is quite with no ticks, correnttime_s doesn't run and doesn't run all commandline commands as well.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby TJ » 04 Apr 2017

::

I didnt understand if currentime_s() really reads the local time of my computer or it refreshes at every tick...
because sometimes, when the market is quite with no ticks, correnttime_s doesn't run and doesn't run all commandline commands as well.

MultiCharts is an event driven program.
ie. it will do a re-calculation of your indicator/strategy whenever a new tick arrives.
The "new tick arrival" being the "event". At other times your indicator will remain dormant.
99% of the charting programs in the market operate this way.

For most of the symbols during business hours, the dormant time is practically non-existant.
For thin markets, or overnight markets, you can force a recal by using the keyword RecalcLastBarAfter.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script  [SOLVED]

Postby TJ » 04 Apr 2017

Thanks @TJ... with your code I have a continuous loop.

::

I have done 3 tests.
First test reloaded twice.
Second test reloaded multiple times.
Third test reloaded once.

Here's what I have deduced:
After a reload, MultiCharts would do a recalc of all the indicators.
ie. the ONCE is reset after the reload. If the time qualifier still holds true, the ONCE will execute again.

In light of this discovery, "ONCE" is not the perfect solution to your situation.

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 04 Apr 2017

Thank you @TJ, you're confirming my thoughts

maybe global variables can be a good workaround

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby ABC » 04 Apr 2017

auoto,

you might want to look into the reserved word recalcpersist (https://www.multicharts.com/trading-sof ... alcPersist) and apply it to your code here: viewtopic.php?t=50624#p125429
You might also need to reset the variable at a later time.

Regards,

ABC

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 08 Apr 2017

@ABC your solution looks like to be great!

automaton
Posts: 47
Joined: 04 Apr 2017
Has thanked: 2 times
Been thanked: 4 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby automaton » 17 Apr 2017

Will commandline within PL code work with multiple charts? When using the command line manually, the selected chart has priority.

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 17 Apr 2017

If I remember well only with some parameters it affects all charts, otherwise it affects only the chart in which the script is active. For example .rld glob acts for all charts while in the example above with .rld int=1 day you will see the reload only for the active chart

automaton
Posts: 47
Joined: 04 Apr 2017
Has thanked: 2 times
Been thanked: 4 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby automaton » 17 Apr 2017

Thanks for responding, but what I meant is: Do they conflict with each other? Example:

PL code/strategy on Chart 1 AAA stock:
If time=1100 then once Commandline(".rld")
If time=1105 then once Commandline("at_toggle")

PL code/strategy on Chart 2 BBB stock:
If time=1100 then once Commandline(".rld")
If time=1105 then once Commandline("at_toggle")

PL code/strategy on Chart 3 CCC stock:
If time=1100 then once Commandline(".rld")
If time=1105 then once Commandline("at_toggle")

Does each chart/instrument have its own Commandline capability, or will one take priority?

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 18 Apr 2017

No conflicts

automaton
Posts: 47
Joined: 04 Apr 2017
Has thanked: 2 times
Been thanked: 4 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby automaton » 19 Apr 2017

auato

Did ABC's solution work for you? Can you post example code? Still trying to get this working

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 20 Apr 2017

Yes, it works for me!

Code: Select all

vars: Recalcpersist RLD(0);

if RLD=0 then Begin
if currenttime_s >=090230 and currenttime_s <090300 then Begin
RLD=1;
Commandline(".rld int=1day");
end;
end;

if RLD=1 then Begin
if currenttime_s >=090300 and currenttime_s <090330 then Begin
Commandline("at_toggle");
RLD=0;
end;
end;

automaton
Posts: 47
Joined: 04 Apr 2017
Has thanked: 2 times
Been thanked: 4 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby automaton » 24 Apr 2017

auato

Thanks for the sample code. It works,, but there is a delay within the 30 second intervals. It takes sometimes more than 20 seconds to execute the commands.

auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby auato » 24 Apr 2017

My understanding is that if the script has IOG enabled all events will be triggered by tick so the delay you are experiencing maybe is depending by the tick frequency

automaton
Posts: 47
Joined: 04 Apr 2017
Has thanked: 2 times
Been thanked: 4 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby automaton » 24 Apr 2017

Probably. Just noticed that at times, it completely skips the command. Had 5 charts open and one of them didn't accept the .at_toggle command. I have an external hotkey script which does the job, but I prefer to work it within MC.

automaton
Posts: 47
Joined: 04 Apr 2017
Has thanked: 2 times
Been thanked: 4 times

Re: .rld command after 2 minutes from the firts daily bar in IOB script

Postby automaton » 04 May 2017

I appreciate the help, but getting the ".at_toggle" to execute command through PL is flaky. I tried it on 10 simultaneous charts with different symbols and a few get completely skipped. I don't think this can be done properly using PL. What we absolutely need is global strategy automation directly at manual command line similar to ".rld glob"


Return to “MultiCharts”