With the portfolio trader not having bar magnifier available, how will this affect walk forward testing with portfolio trader ?
During live sim autotrading, Will portfolio trader only calculate minute data ? HLC data ? Tick data ?
thanks
shane
portfolio trader
-
- Posts: 196
- Joined: 08 Aug 2012
- Has thanked: 41 times
- Been thanked: 41 times
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: portfolio trader
Hello shanemcdonald,
How Signals are Calculated describes this behavior:
Calculation on historical data. Regular mode (IOG disabled. Bar Magnifier disabled)
The script is calculated on the bar close. It's considered that all prices were within the bar (Intra-bar Price movement assumption is used). An order is filled on any price within the bar.
Realtime. Normal mode.
The script is calculated on the bar close. An order is placed on this bar close/next bar open. An order is then filled on any tick price within the next bar.
How Signals are Calculated describes this behavior:
Calculation on historical data. Regular mode (IOG disabled. Bar Magnifier disabled)
The script is calculated on the bar close. It's considered that all prices were within the bar (Intra-bar Price movement assumption is used). An order is filled on any price within the bar.
Realtime. Normal mode.
The script is calculated on the bar close. An order is placed on this bar close/next bar open. An order is then filled on any tick price within the next bar.
Re: portfolio trader
A few related questions:
1) I assume that PT in 9.0 release still does not support IOG or BarMagnifier?
2) If PT does not support IOG, can we assume that strategy orders such as setStopLoss, setBreakEven, setProfitTarget, and setPercentTrailing which the help pages say work on intrabar basis continue to work on intrabar basis in PT?
3) This is not a PT question. I wanted to check my assumption on chart-based IOG-enabled trading with you since the help pages talk about how buy and sell orders have a one bar or one tick duration and are cancelled if not filled within the specified bar or tick.
My confusion is with the word "cancelled" since that can imply hundreds of cancellations being fired at the broker within a bar as the strategy calculates on each tick but the order does not get filled for reasons of liquidity or price limits. I assume MC is not firing hundreds of order cancels at the broker and that what is going on is something like following:
After strategy calculation on a tick, an order is placed. If strategy recalculates the same order on next tick, then nothing is done with the order that was sent to the broker (so no actual cancel takes place). But if strategy does not recalculate the same order, the order with the broker is cancelled.
Thanks.
1) I assume that PT in 9.0 release still does not support IOG or BarMagnifier?
2) If PT does not support IOG, can we assume that strategy orders such as setStopLoss, setBreakEven, setProfitTarget, and setPercentTrailing which the help pages say work on intrabar basis continue to work on intrabar basis in PT?
3) This is not a PT question. I wanted to check my assumption on chart-based IOG-enabled trading with you since the help pages talk about how buy and sell orders have a one bar or one tick duration and are cancelled if not filled within the specified bar or tick.
My confusion is with the word "cancelled" since that can imply hundreds of cancellations being fired at the broker within a bar as the strategy calculates on each tick but the order does not get filled for reasons of liquidity or price limits. I assume MC is not firing hundreds of order cancels at the broker and that what is going on is something like following:
After strategy calculation on a tick, an order is placed. If strategy recalculates the same order on next tick, then nothing is done with the order that was sent to the broker (so no actual cancel takes place). But if strategy does not recalculate the same order, the order with the broker is cancelled.
Thanks.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: portfolio trader
Portfolio trader does not support IOG and BarMagnifier for signals. IOG is supported for the money management signal only.1) I assume that PT in 9.0 release still does not support IOG or BarMagnifier?
When SetStopLoss and other Set*** commands are not under condition (not under begin-end) - they are evaluated intra-bar (even if IOG is off).2) If PT does not support IOG, can we assume that strategy orders such as setStopLoss, setBreakEven, setProfitTarget, and setPercentTrailing which the help pages say work on intrabar basis continue to work on intrabar basis in PT?
That is correct. The orders are valid at broker while they are sent by the strategy. That means the conditions for order generation should be met in your code on each bar close or each tick (if IOG=ON) calculation while you need to keep your orders active. If you want to modify an order - just change the parameter you need (price or quantity) and the order will be modified or cancelled and resubmitted (depends on broker).3) I assume MC is not firing hundreds of order cancels at the broker and that what is going on is something like following: After strategy calculation on a tick, an order is placed. If strategy recalculates the same order on next tick, then nothing is done with the order that was sent to the broker (so no actual cancel takes place). But if strategy does not recalculate the same order, the order with the broker is cancelled.
Re: portfolio trader
Thank you Henry for the explanation. I wanted to clarify some finer points related to this topic.
1) I assume that PT supports signals using second bars and so one can work around the lack of IOG in PT by coding signals using finer grained bars?
2) I assume one can bracket an entry immediately using both setStopLoss and setProfitTarget. Since these are evaluated intrabar even with IOG off, I assume that when you use these set* instructions, it does not result in stop or limit orders being filed with the broker and that instead PT running on my computer evaluates the set* orders on tick-by-tick basis and if any of them are true then a market order is placed with the broker? Please clarify these details about the timing of the orders and the type of orders (stop vs limit vs market).
1) I assume that PT supports signals using second bars and so one can work around the lack of IOG in PT by coding signals using finer grained bars?
2) I assume one can bracket an entry immediately using both setStopLoss and setProfitTarget. Since these are evaluated intrabar even with IOG off, I assume that when you use these set* instructions, it does not result in stop or limit orders being filed with the broker and that instead PT running on my computer evaluates the set* orders on tick-by-tick basis and if any of them are true then a market order is placed with the broker? Please clarify these details about the timing of the orders and the type of orders (stop vs limit vs market).
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: portfolio trader
All data resolutions are supported in Portfolio Trader.Thank you Henry for the explanation. I wanted to clarify some finer points related to this topic.
1) I assume that PT supports signals using second bars and so one can work around the lack of IOG in PT by coding signals using finer grained bars?
It depends on the broker you are using. Please check the Order Types information and the description of the broker profile you are using.2) I assume one can bracket an entry immediately using both setStopLoss and setProfitTarget. Since these are evaluated intrabar even with IOG off, I assume that when you use these set* instructions, it does not result in stop or limit orders being filed with the broker and that instead PT running on my computer evaluates the set* orders on tick-by-tick basis and if any of them are true then a market order is placed with the broker? Please clarify these details about the timing of the orders and the type of orders (stop vs limit vs market).
Re: portfolio trader
Henry,It depends on the broker you are using.2) I assume one can bracket an entry immediately using both setStopLoss and setProfitTarget. Since these are evaluated intrabar even with IOG off, I assume that when you use these set* instructions, it does not result in stop or limit orders being filed with the broker and that instead PT running on my computer evaluates the set* orders on tick-by-tick basis and if any of them are true then a market order is placed with the broker? Please clarify these details about the timing of the orders and the type of orders (stop vs limit vs market).
Thanks for the reply. I will be using IB as broker and would like to understand the details of how auto trading using Portfolio Trader works with IB.
1) To clarify my understanding, even though your help pages say that the built-in set* orders work intrabar, PT running on my computer is not doing a tick-by-tick evaluation (even with IOG off) in the case of IB for setProfitTarget and setStopLoss orders?
2) Assume I entered a long position and my PL code has following two lines for exit at either a profit target or a stop loss. There are three variations and I would like to understand if there are any differences between the variations when it comes to MC/PT to IB interface.
Specifically, please answer the following for all 3 variations: Is the profit target a native IB limit order and the stop loss a native IB stop order and does MC/PT automatically link them in an IB OCA group?
2(a) // exit using two explicit sells
Code: Select all
if (marketPosition = 1) then begin
sell next bar at buyProfitPrice limit;
sell next bar at buyStopPrice stop;
end;
Code: Select all
if (marketPosition = 1) then
sell next bar at buyProfitPrice limit;
setStopLoss(buyStopPrice);
Code: Select all
setProfitTarget(buyProfitPrice);
setStopLoss(buyStopPrice);
end;
4) In other words, the lack of a native modifyOrder() in the IB API works against the trader? (I am not saying this is a MC problem; this is simply the hand that IB is dealing its customers.)
Regards,
orion
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: portfolio trader
That is correct.Henry,
Thanks for the reply. I will be using IB as broker and would like to understand the details of how auto trading using Portfolio Trader works with IB.
1) To clarify my understanding, even though your help pages say that the built-in set* orders work intrabar, PT running on my computer is not doing a tick-by-tick evaluation (even with IOG off) in the case of IB for setProfitTarget and setStopLoss orders?
Limit and Stop orders are supported on broker end: Order types. Such orders can be placed only on bar close in PT. All orders generated on the same calculation are in the OCO group. OCO group can be native and emulated: Interactive Brokers Broker Profile2) Assume I entered a long position and my PL code has following two lines for exit at either a profit target or a stop loss. There are three variations and I would like to understand if there are any differences between the variations when it comes to MC/PT to IB interface.
Specifically, please answer the following for all 3 variations: Is the profit target a native IB limit order and the stop loss a native IB stop order and does MC/PT automatically link them in an IB OCA group?
2(a) // exit using two explicit sells2(b) // exit using explicit sell and a built-inCode: Select all
if (marketPosition = 1) then begin
sell next bar at buyProfitPrice limit;
sell next bar at buyStopPrice stop;
end;Code: Select all
if (marketPosition = 1) then
sell next bar at buyProfitPrice limit;
setStopLoss(buyStopPrice);
If you have such orders under If-Then conditional statement - such orders can be generated only on bar close in PT. If you do not use them under If-Then conditional statement - such orders can be generated and sent intra-bar. IB's native stop and limit orders are sent when setProfitTarget and setStopLoss commands are used.2(c) // exit using two built-inCode: Select all
setProfitTarget(buyProfitPrice);
setStopLoss(buyStopPrice);
end;
IB API supports order modification. This functionality is supported in MultiCharts. Here is an extract from the API documentation:3) I notice that the IB API has a EClientSocket with two methods placeOrder() and cancelOrder() and I am assuming MC/PT uses these two methods to "modify" orders. If my PL code issues a limit order on a bar and then reissues the same order with a different price on the next bar, does that result in a pair of cancelOrder() and placeOrder() messages being fired at IB which means my limit order will go to the back of the queue and thus adversely affect my fill even though I may have modified the limit price in my favor?
4) In other words, the lack of a native modifyOrder() in the IB API works against the trader? (I am not saying this is a MC problem; this is simply the hand that IB is dealing its customers.)
To modify an order using the API, resubmit the order you want to modify using the same order id, but with the price or quantity modified as required. Only certain fields such as price or quantity can be altered using this method. If you want to change the order type or action, you will have to cancel the order and submit a new order.
Re: portfolio trader
Henry,If you have such orders under Begin-End loop - such orders can be generated only on bar close in PT. If you do not use them under Begin-End loop - such orders can be generated and sent intra-bar. IB's native stop and limit orders are sent when setProfitTarget and setStopLoss commands are used.2(c) // exit using two built-inCode: Select all
setProfitTarget(buyProfitPrice);
setStopLoss(buyStopPrice);
end;
Many thanks for the explanations. This is a lot more clear now.
1) Your email mentioned packaging the exit variations (a) and (b) in an IB OCA group. I assume same is done for the built-in pair variation (c)?
2) Regarding orders under "begin-end loop" precluding them from being sent intrabar and being sent intrabar otherwise. That is not clear to me.
Isn't PT currently lacking IOG and so all calculation is being done on bar close and hence such orders can only be sent on bar close by PT even though they may be executed intrabar by IB?
Regards,
orion
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: portfolio trader
Yes, all orders generated on the same calculation are in the same OCO group.Henry,
Many thanks for the explanations. This is a lot more clear now.
1) Your email mentioned packaging the exit variations (a) and (b) in an IB OCA group. I assume same is done for the built-in pair variation (c)?
SetStopLoss function is evaluated intra-bar disregard the IOG if your code is like the following:2) Regarding orders under "begin-end loop" precluding them from being sent intrabar and being sent intrabar otherwise. That is not clear to me.
Isn't PT currently lacking IOG and so all calculation is being done on bar close and hence such orders can only be sent on bar close by PT even though they may be executed intrabar by IB?
Code: Select all
If MarketPosition = 0 then buy next bar at market;
SetStopLoss(); // not under conditional statement
Code: Select all
If MarketPosition = 0 then buy next bar at market;
If MarketPosition = 1 then SetStopLoss(); // under conditional statement