If I use
Once ReCalcLastBarAfter(5) ;
Will code then recalculate ONCE after 5 seconds, or recalculate recurrently after every five seconds? Thanks.
Once with ReCalcLastBarAfter
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Once with ReCalcLastBarAfter
don't use ONCE with it.If I use
Once ReCalcLastBarAfter(5) ;
Will code then recalculate ONCE after 5 seconds, or recalculate recurrently after every five seconds? Thanks.
just add the statement to the code
Code: Select all
ReCalcLastBarAfter(5) ;
Normally an indicator will only recalculate when there is a new tick coming in.
In the absence of new data, there is usually no need to recalculate the indicator because all the parameters will be unchanged. This ReCalcLastBarAfter command forces MultiCharts to recalculate your indicator when the market is thin, and when no new ticks are coming in.
This command is useful if your indicator is time sensitive.
eg. if lapse.time > X minutes then...
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Once with ReCalcLastBarAfter
The keyword ONCE is executed only one time... when you load the indicator into the chart.I do not want it to calculate recurrently, but one time only.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Once with ReCalcLastBarAfter
I don't quite understand your situation, so I don't know where to begin to help you.Thanks TJ. Wasn't sure if there was some feature of ReCalcLastBarAfter that would not make it work with Once.
Can you describe under what scenario you would like to have a recal, but only once?
How would you trigger the recal? manually?
automatically? how?
What if it is recalculated more than once? would it cause an error? Why? How so?
Maybe your situation has a simpler solution than ReCalcLastBarAfter.
Re: Once with ReCalcLastBarAfter
If you have an Indicator set to OFF (not checked) on 'Update every tick' on a Daily bar chart, then Plots will be a day behind, unless you use a timer or ReCalcLastBarAfter, which will cause the code to run and a Plot to appear on today's bar. Once the indicator has run once and the plot is updated, there is no need to run it again and prefer to not have the CPU overhead throughout the day (this is for an indicator that does not use information from today).
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Once with ReCalcLastBarAfter
If your computer is 4 years old, it is probably running at 2GHz,If you have an Indicator set to OFF (not checked) on 'Update every tick' on a Daily bar chart, then Plots will be a day behind, unless you use a timer or ReCalcLastBarAfter, which will cause the code to run and a Plot to appear on today's bar. Once the indicator has run once and the plot is updated, there is no need to run it again and prefer to not have the CPU overhead throughout the day (this is for an indicator that does not use information from today).
it will perform 2,000,000,000 computation per second.
A typical current day trading computer is a quad core running at 3 GHz,
it will do 12,000,000,000 computation per second.
You can set the ReCalcLastBarAfter to 3600, and it won't hurt the computer a tiny bit.
Re: Once with ReCalcLastBarAfter
right. today for example, with 39,000 ES contracts in the ten seconds prior to 3PM and 64,000 ES contracts in the ten seconds after 3PM, I do not want much of anything running besides what is related to current data and current contracts. a tick behind here, a tick behind there.... If it does not NEED to run, I do not want to run it.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Once with ReCalcLastBarAfter
Today is an exception.right. today for example, with 39,000 ES contracts in the ten seconds prior to 3PM and 64,000 ES contracts in the ten seconds after 3PM, I do not want much of anything running besides what is related to current data and current contracts. a tick behind here, a tick behind there.... If it does not NEED to run, I do not want to run it.
Even that, my 4 yrs old computer never missed a beat.
You can try a time condition:
Code: Select all
If time > 1615 then Begin...
Alternatively you can do a manual recal.
View > Reload
- Lobo.Trader
- Posts: 12
- Joined: 26 Nov 2011
- Location: Germany
- Has thanked: 19 times
- Been thanked: 6 times
Re: Once with ReCalcLastBarAfter Keyword "ONCE"
Hello there
me was searching for keyword "ONCE" and found this thread , whilst not finding anything in our MC-documentions (?) .
So , @ TJ , the keyword "ONCE" works same like function " INIT() " in MT4 ? Above, your statement was made re an indicator .Please let me reconfirm , that ONCE works same as MT4 - INIT() for MC - strategies ?
But I will be NOT able to apply "ONCE ... then begin ..code pieces.. end;" ?
Thank you
Lobo
PS.: This is, how I do my initialisation today
Sorry, for German comments , no rocketscience anyhows
me was searching for keyword "ONCE" and found this thread , whilst not finding anything in our MC-documentions (?) .
So , @ TJ , the keyword "ONCE" works same like function " INIT() " in MT4 ? Above, your statement was made re an indicator .Please let me reconfirm , that ONCE works same as MT4 - INIT() for MC - strategies ?
But I will be NOT able to apply "ONCE ... then begin ..code pieces.. end;" ?
Thank you
Lobo
PS.: This is, how I do my initialisation today
Code: Select all
// ==============================================================================================
// INIT () : diese Routine laedt die offenen Trades und holt sich deren Daten
if init = true //
then begin // Initialisierung des HS
init = false ;// Init - Routine nur einmal ausfuehren
// [IntrabarOrderGeneration = True] ;//
ClearPrintLog ;//
Print (" ***** Initialising SLV Stratetgy NutShell *****") ;//
For value1 = 1 to 10 begin
DrawTL[value1,0] = tl_new(0,0,0,0,0,0);// DEBUGG :ID Horizontal Line for Prices
end ;//
// Variable conditions
TickSize = MinMove/PriceScale ;// Abgeguckt
StopLoss1 = stop1*ticksize ;// StopLoss im Preis
Step = stepset*ticksize ;// Trailing Schrittgroesse
end ;//
// ==============================================================================================
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Once with ReCalcLastBarAfter Keyword "ONCE"
Yes. MultiCharts' ..the keyword "ONCE" works same like function " INIT() " in MT4 ?
Code: Select all
once begin
....
end;
Code: Select all
int init()
{
...
return (0);
}
I don't follow you here - do you mean like MT's deinit()? (Code pieces can be placed in the once..begin statement if that's what you mean).But I will be NOT able to apply "ONCE ... then begin ..code pieces.. end;" ?
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Once with ReCalcLastBarAfter Keyword "ONCE"
As far as I follow you, the following code does the same but is "better" and more handier I think:Code: Select all
// ==============================================================================================
// INIT () : diese Routine laedt die offenen Trades und holt sich deren Daten
if init = true //
then begin // Initialisierung des HS
init = false ;// Init - Routine nur einmal ausfuehren
// [IntrabarOrderGeneration = True] ;//
ClearPrintLog ;//
Print (" ***** Initialising SLV Stratetgy NutShell *****") ;//
For value1 = 1 to 10 begin
DrawTL[value1,0] = tl_new(0,0,0,0,0,0);// DEBUGG :ID Horizontal Line for Prices
end ;//
// Variable conditions
TickSize = MinMove/PriceScale ;// Abgeguckt
StopLoss1 = stop1*ticksize ;// StopLoss im Preis
Step = stepset*ticksize ;// Trailing Schrittgroesse
end ;//
// ==============================================================================================
Code: Select all
Variables:
TickSize (MinMove / PriceScale),
StopLoss1 (Stop1 * TickSize),
Step (stepset * TickSize);
//[IntrabarOrderGeneration = TRUE]
// diese Routine laedt die offenen Trades und holt sich deren Daten
once begin
ClearPrintLog;
Print (" ***** Initialising SLV Stratetgy NutShell *****");
For value1 = 1 to 10 begin
DrawTL[value1,0] = tl_new(0,0,0,0,0,0); // DEBUGG :ID Horizontal Line for Prices
end;
end;
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Once with ReCalcLastBarAfter Keyword "ONCE"
Hello there
me was searching for keyword "ONCE" and found this thread , whilst not finding anything in our MC-documentions (?) .
So , @ TJ , the keyword "ONCE" works same like function " INIT() " in MT4 ? Above, your statement was made re an indicator .Please let me reconfirm , that ONCE works same as MT4 - INIT() for MC - strategies ?
...
Sorry, for German comments , no rocketscience anyhows
Sorry, I don't know MT4.
Please read the wiki for keyword explanation.
- Lobo.Trader
- Posts: 12
- Joined: 26 Nov 2011
- Location: Germany
- Has thanked: 19 times
- Been thanked: 6 times
Re: Once with ReCalcLastBarAfter
JoshM , thank you very much for better and more handier code and how to apply "once begin ..end;" .
TJ : "Please read the wiki for keyword explanation" . ....... I did w/o success : within Wiki cannot find "Keyword Alphabetical Index " there in Chaper 5 . And in "Keyword Alphabetical Index " of the PowerLanguage Editor I could not find "ONCE" listed . That than made me post here after having used the search option of the forum and identifying this thread as the most adequate .
What was I doing wrong ? Thank you .
Lobo
PS.: Sorry, for late reply, was traveling entire week and only now returned. @all : Have a great weekend , "blue skies" in Germany wish you the same
TJ : "Please read the wiki for keyword explanation" . ....... I did w/o success : within Wiki cannot find "Keyword Alphabetical Index " there in Chaper 5 . And in "Keyword Alphabetical Index " of the PowerLanguage Editor I could not find "ONCE" listed . That than made me post here after having used the search option of the forum and identifying this thread as the most adequate .
What was I doing wrong ? Thank you .
Lobo
PS.: Sorry, for late reply, was traveling entire week and only now returned. @all : Have a great weekend , "blue skies" in Germany wish you the same
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Once with ReCalcLastBarAfter
Your're right, there is no Once page in the wiki. But there's an small segment in EasyLanguage Essentials (pdf page 57, found here) about it:TJ : "Please read the wiki for keyword explanation" . ....... I did w/o success : within Wiki cannot find "Keyword Alphabetical Index " there in Chaper 5 . And in "Keyword Alphabetical Index " of the PowerLanguage Editor I could not find "ONCE" listed . That than made me post here after having used the search option of the forum and identifying this thread as the most adequate .
What was I doing wrong ? Thank you .
- Lobo.Trader
- Posts: 12
- Joined: 26 Nov 2011
- Location: Germany
- Has thanked: 19 times
- Been thanked: 6 times
Re: Once with ReCalcLastBarAfter
... and also in the Easy Language "Functions & Reserved Words Reference" (TS 8.3.) at page 861 . Should have searched the manuals as well .
Lobo
Lobo
Re: Once with ReCalcLastBarAfter
I don't understand the need to use currentbar in the first example. Also, strictly speaking the first example is executed 4 times, not once. It would be better to use an intrabarpersist variable. Then it will be executed once. The second example using the once keyword is wrong. It doesn't even compile. It must be a typo, and doesn't make sense to use logical tests anyway with a once statement. It should be written as:Your're right, there is no Once page in the wiki. But there's an small segment in EasyLanguage Essentials (pdf page 57, found here) about it:
Code: Select all
var: counter(0);
once begin
counter = 1000;
end;
Code: Select all
var: intrabarpersist counter(0);
once begin
counter = 1000;
end;