Hello,
i noticed that there are some different between backtesting and trading in portfolio trader, i think that it depends of IOG mode of portfolio trader.
In fact, if i print some variable it seems to loop on every tick.
IOG mode can make some error if there are some delay during orders executions, there's any way to avoid this problem and to deny IOG mode in Portfolio trader?
Best Regards
No Erocla
Portfolio: difference between simulation and paper trading
Re: Portfolio: difference between simulation and paper tradi
I try to make an example:
this Portoflio Trader MM Signal limit max open position to Maxopenposition variable:
and this is the Signal to add into the strategy:
So if i run Portfolio backtester all works correctly but if i try active it in Paper Trading, sometimes changes and i can find more order then i want (3) or less orders (0 or 1).
I would appreciate any help
Regards
No Erocla
this Portoflio Trader MM Signal limit max open position to Maxopenposition variable:
Code: Select all
var:idx(0),count(0),maxopenposition(2),countin(0),countout(0),countMP(0),SLOT(0);
array:strategyIndexes[](0);
pmms_strategies_deny_entries_all;
countin = 0;
countout = 0;
COUNTMP = 0;
slot=0;
for idx = 0 to pmms_strategies_count -1 begin
countin = countin + pmms_get_strategy_named_num(idx,"Entry");
countout = countout + pmms_get_strategy_named_num(idx,"Exit");
IF pmms_strategy_marketposition(idx) <> 0 THEN begin
countMP = countMP+1;
end;
end;
SLOT = COUNTMP - countout;
for idx = 0 to pmms_strategies_count -1 begin
if ( pmms_get_strategy_named_num(idx,"Entry") = 1 and SLOT < maxopenposition) then begin
SLOT =SLOT +1;
pmms_strategy_allow_entries(idx);
end;
end;
for idx = 0 to pmms_strategies_count -1 begin
pmms_set_strategy_named_num(idx,"Entry",0);
pmms_set_strategy_named_num(idx,"Exit",0);
END;
if pmms_strategies_in_positions_count(strategyIndexes)> maxopenposition then
print("error ",pmms_strategies_in_positions_count(strategyIndexes));
Code: Select all
inputs:PERIOD(30),ptf(false);
condition98 = true;
IF (marketposition = 0 and condition98 and c < average(c,PERIOD)) then BEGIN
if (ptf = true) then pmm_set_my_named_num("Entry",1);
BUY ( "long" ) 100000 contracts NEXT BAR AT MARKET;
END;
IF (marketposition = 0 and condition98 and c > average(c,PERIOD)) then BEGIN
if (ptf = true) THEN pmm_set_my_named_num("Entry",1);
SELLSHORT ( "short" ) 100000 contracts NEXT BAR AT MARKET;
END;
IF (marketposition = 1 and barssinceentry() >= 1{c > average(c,20)}) then begin
if (ptf = true) then pmm_set_my_named_num("Exit",1);
sell ( "sell" ) 100000 contracts NEXT BAR AT MARKET;
end;
IF (marketposition = -1 and barssinceentry() >= 1{c < average(c,20)}) then begin
if (ptf = true) then pmm_set_my_named_num("Exit",1);
buytocover ( "cover" ) 100000 contracts NEXT BAR AT MARKET;
end;
So if i run Portfolio backtester all works correctly but if i try active it in Paper Trading, sometimes changes and i can find more order then i want (3) or less orders (0 or 1).
I would appreciate any help
Regards
No Erocla
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Portfolio: difference between simulation and paper tradi
Hello No Erocla,
There is a logical error in the open positions counter in your PMM Signal.
There is a logical error in the open positions counter in your PMM Signal.
Re: Portfolio: difference between simulation and paper tradi
Dear Henry,
thank you again for responding.
I still think that anyway there is an error, i made a very simple code to explain it, this is PMM Signal:
And this is Signal:
So in this case, seems impossible that more then 1 strategy can enter at market, and during simulations all works correctly.
The problem occurs just sometimes during real trading
Thank you for your time
Regards
No Erocla
thank you again for responding.
I still think that anyway there is an error, i made a very simple code to explain it, this is PMM Signal:
Code: Select all
var:idx(0),count(0),maxopenposition(1),countin(0);
array:strategyIndexes[](0);
pmms_strategies_deny_entries_all;
countin = 0;
for idx = 0 to pmms_strategies_count -1 begin
if ( pmms_get_strategy_named_num(idx,"Entry") = 1 and countin < maxopenposition ) then begin
countin = countin+1;
pmms_strategy_allow_entries(idx);
end;
end;
if pmms_strategies_in_positions_count(strategyIndexes)> maxopenposition then
print("error ",pmms_strategies_in_positions_count(strategyIndexes));
Code: Select all
inputs:PERIOD(30),ptf(false);
condition98 = true;
IF (marketposition = 0 and condition98 and c < average(c,PERIOD)) then BEGIN
if (ptf = true) then pmm_set_my_named_num("Entry",1);
BUY ( "long" ) 100000 contracts NEXT BAR AT MARKET;
END;
IF (marketposition = 0 and condition98 and c > average(c,PERIOD)) then BEGIN
if (ptf = true) THEN pmm_set_my_named_num("Entry",1);
SELLSHORT ( "short" ) 100000 contracts NEXT BAR AT MARKET;
END;
IF (marketposition = 1 and barssinceentry() >= 1{c > average(c,20)}) then begin
if (ptf = true) then pmm_set_my_named_num("Entry",0);
sell ( "sell" ) 100000 contracts NEXT BAR AT MARKET;
end;
IF (marketposition = -1 and barssinceentry() >= 1{c < average(c,20)}) then begin
if (ptf = true) then pmm_set_my_named_num("Entry",0);
buytocover ( "cover" ) 100000 contracts NEXT BAR AT MARKET;
end;
So in this case, seems impossible that more then 1 strategy can enter at market, and during simulations all works correctly.
The problem occurs just sometimes during real trading
Thank you for your time
Regards
No Erocla
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Portfolio: difference between simulation and paper tradi
Hello No Erocla,
There is still a logical error in this part of your PMM Signal:
Please add traces to debug it.
There is still a logical error in this part of your PMM Signal:
Code: Select all
countin = 0;
for idx = 0 to pmms_strategies_count -1 begin
if ( pmms_get_strategy_named_num(idx,"Entry") = 1 and countin < maxopenposition ) then begin
countin = countin+1;
pmms_strategy_allow_entries(idx);
end;
end;
Re: Portfolio: difference between simulation and paper tradi
I don't know, i'm trying to find a way to fix it.
Anyway, there's some difference beewting simulation and real trading, i don t have problem simulating tousands of trades.
The main question anyway is: why during real trading this logical error occurs just sometimes and not always ?
Regards and thank you again
No Erocla
Anyway, there's some difference beewting simulation and real trading, i don t have problem simulating tousands of trades.
The main question anyway is: why during real trading this logical error occurs just sometimes and not always ?
Regards and thank you again
No Erocla
-
- Posts: 51
- Joined: 04 Jan 2008
- Has thanked: 21 times
- Been thanked: 3 times
Re: Portfolio: difference between simulation and paper tradi
Did you find a solution to this no erocla? Care to share?
Also can you explain what turns ptf to true as you have it at false in your inputs.
Thanks.
Also can you explain what turns ptf to true as you have it at false in your inputs.
Thanks.
Re: Portfolio: difference between simulation and paper tradi
The main problem is the delay beetwin instruments bars close during sorting of array, explained here:
viewtopic.php?f=1&t=49150
viewtopic.php?f=1&t=49150