an incomprehensible problem

Questions about MultiCharts and user contributed studies.
turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

an incomprehensible problem

Postby turbofib » 06 May 2020

hi, look this indicator:

INDICATOR

if false then begin //=======================> IT'S FALSE!!!
Canc_MOTORE(highs(0),lows(0));
end;

FUNCTION

input:RHighh(Numericsimple), RLoww(Numericsimple);

var:RHigh(0),RLow(0);
RHigh=RHighh;
RLow=RLoww;

print(date,time," hallo!!! ");





if Rlow<Rlow[1] then BEGIN {Calcolo mt al ribasso...considerando i low} //==========> if i delete this row, the function is not executed




END;

i see this input:

1200428.00 0.00 hallo!!!
1200428.00 100.00 hallo!!!
1200428.00 200.00 hallo!!!
1200428.00 300.00 hallo!!!
1200428.00 400.00 hallo!!!
1200428.00 500.00 hallo!!!
1200428.00 600.00 hallo!!!

but how it's possible??? the condition is false

User avatar
Smoky
Posts: 507
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 97 times
Been thanked: 115 times

Re: an incomprehensible problem

Postby Smoky » 06 May 2020

Syntax error !

Code: Select all

if Condition1= False then
will work better ...

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: an incomprehensible problem

Postby turbofib » 07 May 2020

Syntax error !

Code: Select all

if Condition1= False then
will work better ...
:x :x :?

if you try it:

INPUT:CONDITION1(false);

if CONDITION1 then begin
Canc_MOTORE(highs(0),lows(0));
end;
the result is egual

User avatar
Smoky
Posts: 507
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 97 times
Been thanked: 115 times

Re: an incomprehensible problem

Postby Smoky » 07 May 2020

To evaluate an expresion, you need to use 2 parameters with equal, not equal, < ,>, ....

Code: Select all

INPUT:CONDITION1(false); if CONDITION1=False then begin Canc_MOTORE(highs(0),lows(0)); end;

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: an incomprehensible problem

Postby turbofib » 07 May 2020

"if condition1=true then" or "if conditio1 then " is the same result!

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: an incomprehensible problem

Postby turbofib » 07 May 2020

does anyone else understand why?

Mydesign
Posts: 177
Joined: 15 Feb 2017
Has thanked: 32 times
Been thanked: 39 times

Re: an incomprehensible problem

Postby Mydesign » 08 May 2020

Correct, you can ommit "=true" to assess a condition as true, but not "=false"...

As Smocky mentioned you can write:

Code: Select all

If condition1 then
which is the same as

Code: Select all

If condition1 = True then
But to test if false you need to write:

Code: Select all

If condition1 = false then

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: an incomprehensible problem

Postby turbofib » 08 May 2020

ok thanks for the information ... but you are running away from the main problem

I repeat my problem:

Indicator:
var:pass(false);
if pass then begin //=======================> IT'S FALSE!!!
Canc_MOTORE(highs(0),lows(0));
end;

Function:
input:RHighh(Numericsimple), RLoww(Numericsimple);

var:RHigh(0),RLow(0);
RHigh=RHighh;
RLow=RLoww;

print(date,time," hallo!!! ");
if Rlow<Rlow[1] then BEGIN {Calcolo mt al ribasso...considerando i low} //==========> if i delete this row, the function is not executed
END;


i see this input:

1200428.00 0.00 hallo!!!
1200428.00 100.00 hallo!!!
1200428.00 200.00 hallo!!!
1200428.00 300.00 hallo!!!
1200428.00 400.00 hallo!!!
1200428.00 500.00 hallo!!!
1200428.00 600.00 hallo!!!

but how it's possible??? the condition is false

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

Re: an incomprehensible problem

Postby JoshM » 10 May 2020

Does this problem also happen when you set the MaxBarsBack for the indicator explicitly? (So instead of automatic MaxBarsBack detection.)

If that's the case, then this problem happens because MultiCharts has to inspect your function to see how many historical bars it needs for its computations. From this wiki page it says:
The process of automatic MaxBarsBack detection may cause some functions to be executed repeatedly for the first few bars of a chart when a study is first applied; this can be avoided by setting the MaxBarsBack value manually.
However, when MultiCharts tests your function in order to estimate the number of max bars back, the `Print()` statement in the code also triggers. But MultiCharts cannot know what historical data your function needs without testing (running) it first. So it's a bit of peculiar situation. :)

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: an incomprehensible problem

Postby turbofib » 11 May 2020

hi josh, i set maxbarsback not from code but in the property strategy
Attachments
Immagine.png
(20.22 KiB) Not downloaded yet

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: an incomprehensible problem

Postby sptrader » 11 May 2020

Is Condition1 defined anywhere ?

Such as :

Code: Select all

Condition1 = High > Close;
Then say something like

Code: Select all

If condition1 = true then begin

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

Re: an incomprehensible problem

Postby ABC » 11 May 2020

turbofib,

this is expected behavior for functions of the type series. Multicharts will call them with every code calculation, even if your code seemingly calls them conditionally only. You might have the function type set to auto detect and when you remove the following line the function becomes simple:

if Rlow<Rlow[1] then BEGIN {Calcolo mt al ribasso...considerando i low} //==========> if i delete this row, the function is not executed

As simple functions can be called conditionally the results you are seeing a perfectly in line with how Multicharts works.

Regards,

ABC
ok thanks for the information ... but you are running away from the main problem

I repeat my problem:

Indicator:
var:pass(false);
if pass then begin //=======================> IT'S FALSE!!!
Canc_MOTORE(highs(0),lows(0));
end;

Function:
input:RHighh(Numericsimple), RLoww(Numericsimple);

var:RHigh(0),RLow(0);
RHigh=RHighh;
RLow=RLoww;

print(date,time," hallo!!! ");
if Rlow<Rlow[1] then BEGIN {Calcolo mt al ribasso...considerando i low} //==========> if i delete this row, the function is not executed
END;


i see this input:

1200428.00 0.00 hallo!!!
1200428.00 100.00 hallo!!!
1200428.00 200.00 hallo!!!
1200428.00 300.00 hallo!!!
1200428.00 400.00 hallo!!!
1200428.00 500.00 hallo!!!
1200428.00 600.00 hallo!!!

but how it's possible??? the condition is false


Return to “MultiCharts”