LastBarOnChart_s = True  [SOLVED]

Questions about MultiCharts and user contributed studies.
waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

LastBarOnChart_s = True

Postby waldem » 14 Apr 2016

Hallo, someone could explain me what does it mean exhactly this keyword? i cannot find it.

i have problem with simple code:

Code: Select all

if (LastBarOnChart_s = True) then begin
RecalcLastBarAfter(0.001);

if marketposition<>1 then buy next bar at insidebid limit;

end;
the problem is that if book is very liquid like future you never see problem, if book is stuck like bond or minor stock, the routine recalc will not start before one exchange.
if there is new last that someone buy or sell something, after the routine start not before.

maybe is one flag to put somewhere?

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

Re: LastBarOnChart_s = True

Postby TJ » 14 Apr 2016

LastBarOnChart is not a keyword, it is a function. That is why you could not find it under the keywords listing.

You can open the script and inspect the code to see how it works.

LastBarOnChart (Function)


The LastBarOnChart function is used to determine if the current bar being evaluated is the last bar on the chart.

Syntax
LastBarOnChart

Returns (Boolean)
True if LastBarOnChart is the last charted bar. False if not.

Parameters
None

Example
In order to play a wave (sound) file only in the last bar of the chart you can write:

If LastBarOnChart Then
Condition1 = PlaySound("C:\window\ding.wav");

This function will return True for all bars on a chart with tick-based interval, which have the same date and time as the last bar of the chart.

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

Re: LastBarOnChart_s = True

Postby TJ » 14 Apr 2016

ps. RecalcLastBarAfter

Note: The maximum recalculation frequency is 100 milliseconds (0.1 sec).


ie.

These settings are ok

RecalcLastBarAfter(0.1)
RecalcLastBarAfter(0.5)
RecalcLastBarAfter(1)

These settings are not ok

RecalcLastBarAfter(0.01)
RecalcLastBarAfter(0.001)

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: LastBarOnChart_s = True

Postby waldem » 14 Apr 2016

Thank you TJ, i cannot understand why sometimes i don't go to the market..

are ok my properties in your opinion?

some other settings to do?

or maybe is my brocker problem.

thanks again..
Attachments
set.png
(20.46 KiB) Downloaded 965 times

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

Re: LastBarOnChart_s = True

Postby TJ » 14 Apr 2016

Thank you TJ, i cannot understand why sometimes i don't go to the market..
are ok my properties in your opinion?
some other settings to do?
or maybe is my brocker problem.
thanks again..
What do you mean by "sometimes i don't go to the market.."?

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: LastBarOnChart_s = True

Postby waldem » 14 Apr 2016

very simple, sometimes it happen that i press "SA" button and i don't go in the book, simply nothing happen.
i'm still investigating if is recalc problem, MC problem, broker, plugin, i don't know.
what is strange is that MC does not send anything, normally if is broker problem i should receive any error, in this case also if you open the log window you will see no order sent.... it seems that MC wait for something..

waldem
Posts: 115
Joined: 18 Nov 2013
Has thanked: 3 times
Been thanked: 4 times

Re: LastBarOnChart_s = True

Postby waldem » 15 Apr 2016

today after milions of try i have understand the problem and in my personal opinion have no sense; even if you have the recalc or not, when you apply any strategy to one chart, MC need to register one exchange, one new bar on chart; after this you can apply whatever you whant for the rest of the day that go immediately on book without wait...
but if i would like to work in BONDS maybe they have 2 exchange per day and i cannot go on book...

Henry should i contact you in chat to show the problem?
maybe you already know and simply MC works like that?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: LastBarOnChart_s = True  [SOLVED]

Postby Henry MultiСharts » 15 Apr 2016

It was required to add the attribute [AllowSendOrdersAlways=true] to the code.


Return to “MultiCharts”