EntryPrice(x) reserved word does not change when pyramiding

Questions about MultiCharts and user contributed studies.
RS
Posts: 39
Joined: 28 Sep 2007

EntryPrice(x) reserved word does not change when pyramiding

Postby RS » 19 Nov 2007

Marina,

I try to change a strategy to a pyramiding strategy but I can't get the right EntryPrices for positions greater than the first position. It looks like that the reserved words could not handle pyramiding? They don't change after the first position. Can you help me with this?

Thanks,
Rob.

Sample code:

If CurrentPosition >= 0 then begin
Sell Short ("Short Entry#1") This Bar 1 contracts on Close;
CurrentPosition = -1;
end
else
If CurrentPosition = -1 AND MaxPosSize > 1 AND (EntryPrice(0) - Close) * VarBigPointValue >= PyramidingProfit then begin
Sell Short ("Short Entry#2") This Bar 1 contracts on Close;
CurrentPosition = -2;
end
else
If CurrentPosition = -2 AND MaxPosSize > 2 AND (EntryPrice(0) - Close) * VarBigPointValue >= PyramidingProfit then begin
Sell Short ("Short Entry#3") This Bar 1 contracts on Close;
CurrentPosition = -3;
end
else
If CurrentPosition = -3 AND MaxPosSize > 3 AND (EntryPrice(0) - Close) * VarBigPointValue >= PyramidingProfit then begin
Sell Short ("Short Entry#4") This Bar 1 contracts on Close;
CurrentPosition = -4;
end
else
If CurrentPosition = -4 AND MaxPosSize > 4 AND (EntryPrice(0) - Close) * VarBigPointValue >= PyramidingProfit then begin
Sell Short ("Short Entry#5") This Bar 1 contracts on Close;
CurrentPosition = -5;
end;
print (time, " EP(0): ", EntryPrice(0), " EP(1): ", EntryPrice(1), " EP(2): ", EntryPrice(2), " EP(3): ", EntryPrice(3), " EP(4): ", EntryPrice(4));

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 19 Nov 2007

Hi Rob,

We couldn't compile the code above. Could you please give us the full script which can be compiled in PLEditor? Also, we do not know what CurrentPosition, MaxPosSize, VarBigPointValue, PyramidingProfit are. Could you please comment on those?

Thank you.

Best regards

RS
Posts: 39
Joined: 28 Sep 2007

Postby RS » 19 Nov 2007

Marina,

Thanks for your quick answer. Because it's a urgent problem for me I called also the phone helpdek (spoke to Surgey?) who asked me to send my problem via help@tssupport.com. Because I've already contact with you now, I will not send it again via email.

The code I provided was only part of my strategy: I thought/hoped that the problem was known to you so I didn't make the code ready to compile. Now you're asking, I made it specific. It doesn't matter on which chart you run it, the reserved words does not change after the first position.

Thanks in advance,
Rob.

P.S. The quality of the phone line was very bad; It was very hard to understand Surgey. Do you use VOIP? I remarked a big latency.

If BarNumber = 1 then begin
Sell Short ("Short Entry#1") This Bar 1 contracts on Close;
end;
If BarNumber = 2 then begin
Sell Short ("Short Entry#2") This Bar 1 contracts on Close;
end;
If BarNumber = 3 then begin
Sell Short ("Short Entry#3") This Bar 1 contracts on Close;
end;
If BarNumber = 4 then begin
Sell Short ("Short Entry#4") This Bar 1 contracts on Close;
end;
If BarNumber = 5 then begin
Sell Short ("Short Entry#5") This Bar 1 contracts on Close;
end;
if BarNumber < 6 then print (time, " EP(0): ", EntryPrice(0), " EP(1): ", EntryPrice(1), " EP(2): ", EntryPrice(2), " EP(3): ", EntryPrice(3), " EP(4): ", EntryPrice(4));

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 19 Nov 2007

Hi Rob,

The reserved words won't change their value until the script has been calculated. The order's price is not known until it's generated. And all orders are submitted after all the scripts have been calculated.

If you compare the script's behaviour in TS you can see that it's identical to that of MultiCharts.

If you need a more detailed explanation please let me know.

Regards.

RS
Posts: 39
Joined: 28 Sep 2007

Postby RS » 19 Nov 2007

Marina,

I don't understand your answer completely.

This script is called every bar, during the first bar only 1 position is taken, the second bar (when the script for the first bar is finished) the second position is taken and so on. I thought that the code/script is calculated for every bar?

Regards,
Rob.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 20 Nov 2007

Hi Rob,

The description below of how the position works might help to understand the issue above:

A trading position starts with the first entry order (Buy, SellShort) and ends where MarketPosition changes (after the complete exit, or reversal into the opposite position).

EntryPrice returns the entry price for the specified position.
EntryPrice assumes the parameter position_ago. In other words, which position's EntryPrice is of importance for us (0 is the current position. 1 the previous one etc). EntryPrice without parameters returns EntryPrice of the current position (same as EntryPrice(0)). EntryPrice returns the price of the very first entrance into the position.

In the example above, the current position has been opened but it hasn't been closed yet (or reversed).

Hope the above helps. If you need further explanation please let me know.

Best regards.

RS
Posts: 39
Joined: 28 Sep 2007

Postby RS » 20 Nov 2007

Marina,

Thanks for your explanation. You are faster than the response I would give you on basis of my research:

I ran the same code with TS2000i and got, like you said, the same results. That's when some bells rang; my understanding of a position/entry was wrong. I thought that a position/entry was the same as an order, so several orders where as much as positions (entries). Now I know...

Thanks again for your fast and clear explanation and your patience with learning customers...

Regards,
Rob.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 20 Nov 2007

Hi Rob,

I'm glad I've been able to help. If you have any questions again don't hesitate to ask.

Regards.

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

Postby ABC » 20 Nov 2007

Rob,

take a look at the reserved word "avgentryprice", this will give you the average entry price of each open entry in a pyramided position.
For every single added contract you can store the entryprice in a variable for example, if the average entry price is not what you are looking for.

Best regards,
ABC

RS
Posts: 39
Joined: 28 Sep 2007

Postby RS » 21 Nov 2007

ABC,

Thanks for your advice. I tested it and it works with MC 2.1.999 The strange thing is that the reserved word avgentryprice is on the list of "not supported reserved words".

Do you know which strategy reserved words does work and which not with MC 2.1.999?


With regards,
Rob.

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

Postby ABC » 21 Nov 2007

Rob,

I remember that it didn't work a couple of releases ago and I was happy to see that it does now yesterday. I am sorry, but I don't have an updated list of working reserved words, I am starting out from the TS Support list, too.

Best regards,
ABC

RS
Posts: 39
Joined: 28 Sep 2007

Postby RS » 21 Nov 2007

ABC,

I copied the complete list of "not reserved words" out of the post and paste it into PLEditor; the colors (blue or red) gives the answer :-).

Regards,
Rob.

2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Blue:supporte, Red: Not Supported, and Gray:???

Postby 2haerim » 21 Nov 2007

What are gray colors?

I found the answer myself: those are typos in the list and they should be

totalbarseventrades
totalbarslostrades
totalbarswintrades

but , not

totalbarsevemtrade
totalbarslostrade
totalbarswintrade

<P.S>

Marina, please correct typos and also update the list.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 22 Nov 2007

Hi HaeRim,

Thank you for pointing those out.

2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Does ClearDebug work correctly?

Postby 2haerim » 22 Nov 2007

ClearDebug is supposed to clear the Output window, but it does not at all.

Please check this.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 23 Nov 2007

Hi HaeRim,

It was just confirmed that it's a bug.

Thank you for drawing our attention to the issue.


Return to “MultiCharts”