i_AvgEntryPrice, EntryPrice, currentcontracts are all empty

Questions about MultiCharts and user contributed studies.
simon007
Posts: 60
Joined: 12 Apr 2007
Has thanked: 7 times
Been thanked: 1 time

i_AvgEntryPrice, EntryPrice, currentcontracts are all empty

Postby simon007 » 12 Nov 2010

When I run the following signal, for some reason the strategy position logicals are empty, help.....

Code: Select all

var: intrabarpersist BarNo(0), LogText("");

If LastBarOnChart then
begin
Buy next bar 1 contracts at market;
If BarNo<>BarNumber then
begin
LogText = "Entryprice : "+NumToStr(i_AvgEntryPrice, 2)+" ("+NumToStr(i_CurrentContracts, 0)+" contracten)";
print((File("C:\logfile.txt"), LogText);
BarNo = BarNumber;
end;
end;

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: i_AvgEntryPrice, EntryPrice, currentcontracts are all em

Postby Dave Masalov » 12 Nov 2010

Dear simon007,

This strategy will buy in real-time, when the next bar, after the strategy is applied, comes (because of If LastBarOnChart condition). Did you want this?

simon007
Posts: 60
Joined: 12 Apr 2007
Has thanked: 7 times
Been thanked: 1 time

Re: i_AvgEntryPrice, EntryPrice, currentcontracts are all em

Postby simon007 » 12 Nov 2010

Hi Dave,

It's just a check, because in my real strategy i_AvgEntryPrice, EntryPrice and currentcontracts all return 0

Simon

simon007
Posts: 60
Joined: 12 Apr 2007
Has thanked: 7 times
Been thanked: 1 time

Re: i_AvgEntryPrice, EntryPrice, currentcontracts are all em

Postby simon007 » 12 Nov 2010

I have intrabar order generation disabled, maybe this is the reason all these logicals are empty. The actual order isn't generated until the bar closes.

simon007
Posts: 60
Joined: 12 Apr 2007
Has thanked: 7 times
Been thanked: 1 time

Re: i_AvgEntryPrice, EntryPrice, currentcontracts are all em

Postby simon007 » 12 Nov 2010

I found it!

There is a difference between issuing a order and executing the actual order. These logicals are filled after the order has been executed. I you check these logicals right after the trade has been issued. there not filled. I wait for the market position to change compared to the previous market position, as soon as this happens these logicals are filled

Simon
Last edited by simon007 on 12 Nov 2010, edited 1 time in total.

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: i_AvgEntryPrice, EntryPrice, currentcontracts are all em

Postby Dave Masalov » 12 Nov 2010

Dear Simon,

Glad to hear the the problem has been solved.


Return to “MultiCharts”