Is an IOG enabled code back-testable? If yes, How?

Questions about MultiCharts and user contributed studies.
Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Is an IOG enabled code back-testable? If yes, How?

Postby Spaceant » 30 Jun 2010

as title....

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 30 Jun 2010

Backtest Precision/resolution set to 1 tick should give close to real trade results. ( my view)

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 30 Jun 2010

Backtest Precision/resolution set to 1 tick should give close to real trade results. ( my view)
Where can I set it?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 30 Jun 2010

Backtest Precision/resolution set to 1 tick should give close to real trade results. ( my view)
Where can I set it?
press [F1]

look under

MultiCharts > Strategy Trading > Backtesting
> Understanding Precise Back Testing
> Using Precise Strategy Back Testing

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 01 Jul 2010

Thanks TJ!

1) But I can't select "Extended" strategy backtesting when using "MultiCharts Portfolio Backtester" ..... where can I set it?

2) Well, I want to test an IOG enabled strategy on a ticker with 5-min timeframe. It appears to me that the database should have the bid/ask data series on top of the trade data series. BUT, my data was imported with the trade data series. Does it mean that there is no way to test it?

3) The reason why I initiated this thread is because it was by the TSSupport that there is a bug in trading with the built-in "Percent Trailing" when using MC6.0 Beta2 or prevous versions, in which it has used the SetPercentTrailing.

I have tested it in realtime with IB's paper trading account, the chart did plot the exit using the right calculation of SetPercentTrailing, but MC didn't seem sending the trailing stop order to IB. So there is a situation that the chart plotting an exit with the position is still in IB's TWS.

I don't want to trade with the beta version (MC 6.0 Beta4 or 3) as it appears to be risky my money to learn some potential but unknown bugs or program instability.

I only solution is to wait for the offical version or do it my way.

4) So I code the concept of SetPercentTrailing using an IOG enabled code to do the job. I have added a 'trigger level' ("PST" in the following code, Protective Stop Trigger) to initiate the Trailing Stop.
{PST then %Trailing}

[IntrabarOrderGeneration = true]
inputs: PST(300),PctTrailing(10);
variables: MP(0),MCP(0),BSE(0),HH(0),LL(0),EP(0),BStop(0),SStop(0);

MP = MarketPosition ;
MCP = MaxContractProfit/bigpointvalue;
BSE=BarsSinceEntry;
HH=Highest(H,BSE);
LL=Lowest(L,BSE);
EP=entryprice;
BStop=HH-(HH-EP)*PctTrailing/100;
SStop=LL+(EP-LL)*PctTrailing/100;

If MP=1 and MCP>PST then sell ("%T-LX") next bar at BStop Stop;
If MP=-1 and MCP>PST then buy to cover ("%T-SX") next bar at SStop Stop;
It matches almost 100% as the built-in code, SetPercentTrailing, when applying to a short period of data.

I haven't tested it in realtime, but I would think of the following potential problem:

Potential Problem: If the price exceeds the PST level, and keeps on breaking the new highs / lows every tick, I will presume MC will change the Trailing Stop order every tick. Does it mean that the maximum number of changes of order is 60 per second?? (If anyone is familiar with this, please correct me if I am wrong!!)

Does IB "refuse" the user to change the order if it exceed a certain number of order say per 1 min? I can't find it in IB's site.

The second thing is to backtested the strategy, but it doesn't seem right in comparison of the results applying the built in code using SetPercentTrailing as I use the data with trade data series only, and I use Portfolio Backtester in which I can't find any "Extended" strategy backtesting option to be selected. Even with this option, my data is with trade data series only. I am not sure if it is difference is due to the lack of accurate bid / ask data for testing.

Hope any of the experts can help me!!

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 01 Jul 2010

Thanks TJ!

1) But I can't select "Extended" strategy backtesting when using "MultiCharts Portfolio Backtester" ..... where can I set it?

...

see this thread for answer:
http://forum.tssupport.com/viewtopic.php?t=7497

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

Postby Dave Masalov » 01 Jul 2010

Dear Spaceant,

1) There is no Extended backtesting in Portfolio Backtester for the moment. However, we plan to add it in the future.

2) IOG means that the strategy is calculated on evey tick. There is no need for bid/ask data series, trades are enough.

3) The SetPercentTrailing bug was fixed in Beta 4 version.

4)
Potential Problem: If the price exceeds the PST level, and keeps on breaking the new highs / lows every tick, I will presume MC will change the Trailing Stop order every tick. Does it mean that the maximum number of changes of order is 60 per second?? (If anyone is familiar with this, please correct me if I am wrong!!)
Yes, you are right, MC will change the Trailing Stop order every tick, if the price exceeds the PST level, and keeps on breaking the new highs / lows every tick. But it does not mean that the maximum number of changes of order is 60 per second. It depends on how many ticks comes every second (maybe 100, may be 0).
Does IB "refuse" the user to change the order if it exceed a certain number of order say per 1 min? I can't find it in IB's site.
Please contact IB with this question.
The second thing is to backtested the strategy, but it doesn't seem right in comparison of the results applying the built in code using SetPercentTrailing as I use the data with trade data series only, and I use Portfolio Backtester in which I can't find any "Extended" strategy backtesting option to be selected. Even with this option, my data is with trade data series only. I am not sure if it is difference is due to the lack of accurate bid / ask data for testing.
Could you please precise the question?

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 02 Jul 2010

Yes, you are right, MC will change the Trailing Stop order every tick, if the price exceeds the PST level, and keeps on breaking the new highs / lows every tick. But it does not mean that the maximum number of changes of order is 60 per second. It depends on how many ticks comes every second (maybe 100, may be 0).
Dave,

Will MC do anything if price exceeds PST and the new tick does not exceed new high / low? .... the reason why I ask it as in IOG mode, MC will treat every tick as a new bar, so MC will, as I think, canceal the previous trailing stop order, then place a new 'trailing stop order' with the SAME price (as no new high / low). Am I right?

If this is right, with the above code, MC will be very busy with every tick cancealing old trailing stop order and updating a new one....... will that be an issue for MC or IB?

I am just just wondering how the SetPercentTrailing handles the trailing stop order......

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 06 Jul 2010

Hi Dave,

On top of the two questions in the previous post, I would like to know that following:
2) IOG means that the strategy is calculated on evey tick. There is no need for bid/ask data series, trades are enough.
Do I need to check the box to "Use Bar Magnigier (1 tick)", under Backtesting Precision of Backtesting, when I trade the standard / pre-installed SetPercentTrailing or my code?

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

Postby Dave Masalov » 07 Jul 2010

Will MC do anything if price exceeds PST and the new tick does not exceed new high / low? .... the reason why I ask it as in IOG mode, MC will treat every tick as a new bar, so MC will, as I think, canceal the previous trailing stop order, then place a new 'trailing stop order' with the SAME price (as no new high / low). Am I right?
Do I need to check the box to "Use Bar Magnigier (1 tick)", under Backtesting Precision of Backtesting, when I trade the standard / pre-installed SetPercentTrailing or my code?
Dear Spaceant,

If the price orders do not change on the next tick (the number of orders, number of contracts, direction and price are the same), then the orders are not cancelled, they stay.


As to Bar Magnigier, it works only for history, it is not needed for real-time.

User avatar
Henrik
Posts: 140
Joined: 13 Apr 2010
Has thanked: 25 times
Been thanked: 11 times

Postby Henrik » 07 Jul 2010

Keep in mind:
Use IntraBarPersist for variables/arrays when use IOG!

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Postby Spaceant » 10 Jul 2010

This is the message just received from IB:
NOTICE OF HIGH ORDER RATIO

Dear Trader,
We have noticed a very high ratio of orders and order modifications relative to the number of executions in your account XXXXXXX. Every order instruction submitted by you (includes new order submission, order modification, cancellation) utilizes computing power. Excessive order activity can slow down IB systems and negatively impact other clients.
IB monitors order/trade ratios to prevent excessive and unnecessary system resource utilization. As a general rule, a ratio value less than 10 order actions per 1 execution will generally be acceptable, although fees may apply for certain markets where the ratios exceed 5:1. Above 20:1, IB will request clients using automated order management tools to optimize their order management behavior. Above 100 orders per execution, or if our analysis indicates a systematic misuse of IB's automation services, IB may take steps to reduce the system utilization including: charging a fee for order modifications (typically 20% of the commission for an execution), or limiting access to API services.
Most of the time, excessive order/trade ratios are caused by poorly optimized APIs or other order creation programs. These applications generate price changes that do not materially alter the likelihood of the order being filled. By example, when a stock is quoted 50.0-50.2, then an order change from 45 to 46 does not really change the likelihood of execution.
Most clients are able to easily improve their order management by introducing "no-waste" logic into their systems. We kindly request you examine your order management logic to reduce unnecessary orders to the recommended levels. Statistics for the recent observations are:
Ratio: 21.38
Number of New Order Submissions: 142
Number of Order Modifications: 0
Number of Order Cancellations: 136
Number of Executions: 12

For additional information, including suggestions as to how to reduce waste in your order management behavior, please type KB1343 http://ibkb.interactivebrokers.com/node/1343 into the search engine located on the IB home page or contact our API services group at api@interactivebrokers.com
I was using my Trailing Stop code as posted earlier, as I don't want to use MC6.0 Beta 4 to trade.

I a wondering whether the standard SetPercentTrailing will change the trailing order as frequently as my code does!!??

Does anyone use SetPercentTrailing to trade, please comment!


Return to “MultiCharts”