Portfolio Trader - multiple iteration issue

Questions about MultiCharts and user contributed studies.
no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Portfolio Trader - multiple iteration issue

Postby no erocla » 18 Nov 2015

I will post sample codes to show what i mean:

Signal:

Code: Select all

pmm_set_my_named_num("flag_signal",1);
Portfolio trader Signal:

Code: Select all

variables: flag(false),idx(0);
flag = FALSE;

//// Control for flag from signals
for idx = 0 to pmms_strategies_count -1 BEGIN
IF (pmms_get_strategy_named_num(idx,"flag_signal") <> 0 ) then flag = true;
end;

//// Put all variabile to zero to block next cycle
for idx = 0 to pmms_strategies_count -1 begin
pmms_set_strategy_named_num(idx,"flag_signal",0);
end;

if flag = true then begin
flag = FALSE;
//// Put all variabile to zero to block next cycle
for idx = 0 to pmms_strategies_count -1 begin
pmms_set_strategy_named_num(idx,"flag_signal",0);
end;
print("MINUTE ", MinutesFromDateTime(DATETIME)," HERE");

END;

//// Put all variabile to zero to block next cycle
for idx = 0 to pmms_strategies_count -1 begin
pmms_set_strategy_named_num(idx,"flag_signal",0);
end;
For example, using 1 minute timeframe, i expect to see printed "HERE" just 1 time per minute, but this does not happen and sometimes is printed 3/4 times, becoming from some multiple iteration.

Thank you so much for any response

Regards
No Erocla

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

Re: Portfolio Trader - multiple iteration issue

Postby Henry MultiСharts » 20 Nov 2015

Hello no erocla,

We were unable to replicate this behavior on our end in MC 9.1 Release 2 build 12009 with the attached test workspace.

Please send us the following information for analysis of this case to support@multicharts.com:
- workspace you are using;
- in QuoteManager select the symbols you are using, make a right click on it->Export data->Export instrument (with data). Send us the QMD export file for analysis;
- in PowerLanguage editor->File->Export->export with dependent functions the studies you are using in the workspaces you are providing. Send the study export file;
- specify the version and build number of MultiCharts you are running (in MultiCharts go to Help tab-> About);
- your output log that demonstrates the issue;
- instructions for replicating the error.
Attachments
MyWSP.pws
(33.38 KiB) Downloaded 511 times

no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Re: Portfolio Trader - multiple iteration issue

Postby no erocla » 23 Nov 2015

Dear Henry, thank you for response, i send all in this thread too:

this is the error that i mean:

Image

The versione is the latest (downloaded now): MultiCharts64 Version 9.1 Release (Build 12010)
Regards
No Erocla
Attachments
Issue.rar
(91.45 KiB) Downloaded 221 times

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

Re: Portfolio Trader - multiple iteration issue

Postby Henry MultiСharts » 24 Nov 2015

Hello No Erocla,

Our engineers have studied your inquiry. The sequence of the calculations in Portfolio Trader is correct.
Let me clarify:
Portfolio trader does not support IOG and BarMagnifier for trading signals.
IOG is supported for the money management signal only.

In backtesting (on historical data):
All bars in backtesting are closed. The trading signal is calculated on bar close only. After all trading signals are calculated for all data series - the money management signal is calculated. You can find more detailed description in our Wiki:
https://www.multicharts.com/trading-sof ... lio_Trader

In forward testing/realtime trading:
The money management signal needs to know the events of all data series therefore it is called on each new tick (runs in IOG).
In realtime the bars are closed asynchronously. It means the data series are closing not in the order they are listed in the portfolio. The money management signal is called upon close of each data series, because it should not miss any event (the data series can be of different resolution and the base series can be not updating).

no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Re: Portfolio Trader - multiple iteration issue

Postby no erocla » 24 Nov 2015

Dear Henry, thank you for response and your time.

I understand this but i think that to avoid some loop problems you have to give the possibility to set a timeframe to portfolio trader based on computer time, or some instruments data close.

Best regards
No Erocla

no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Re: Portfolio Trader - multiple iteration issue

Postby no erocla » 22 Dec 2015

Dear Henry,

i think that this problem can occurs in Portfolio Rank MM Signal too.

For example, when i sort an array, i allow to the first "n" signals to go long.

https://gyazo.com/4fa58f161d92614cc31cd859f118cbfd

So i've maximum long system at market equal to 3.
But what happen when there is an asynchrony beetwin bars close, and "value" changes after new PMM Signal refresh ?

https://gyazo.com/7ecd3f50d3f2cbd2158be72dca968860

In this case, we will have 4 systems allowed to go long and not just 3.

Thank you for any answer
Regards
No Erocla

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

Re: Portfolio Trader - multiple iteration issue

Postby Henry MultiСharts » 24 Dec 2015

Hello No Erocla,

4th strategy will not open a position as MM signal code will not allow it:

Code: Select all

int inLong = this.StrategiesInLong(ref strategies);
for (int idx = 0; idx < BuyBestX - inLong; idx++) {}
The script first checks the number of strategies that already have an open position, then, if possible, this list is extended in a cycle:

Code: Select all

idx < BuyBestX - inLong

no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Re: Portfolio Trader - multiple iteration issue

Postby no erocla » 31 Dec 2015

Dear Henry,

What i mean is that when you sort an array and allow "n best" strategy to enter at market, for example:

allow : strategy 4
allow : strategy 2
allow : strategy 3
deny : strategy 1

is possibile that after some milliseconds/seconds another signal want to enter at market and so the array will be re-sorted very fast again:

allow : strategy 1
allow : strategy 2
allow : strategy 3
deny : strategy 4

during this period, portfolio trader does not have time to check if actually there's some open position (because you send order to the broker and he needs time to open your trade).
So in this case, array will be re-sorted, strategy in position count is equal to zero, and you deny strategy 4 AFTER that PTF Trader has just sent the order to the Broker.
This has like result 4 open position at market.

no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Re: Portfolio Trader - multiple iteration issue

Postby no erocla » 19 Jan 2016

Someone notice the same behavior ?


Return to “MultiCharts”