GTC order

Questions about MultiCharts and user contributed studies.
stockmacd
Posts: 23
Joined: 28 Feb 2007

GTC order

Postby stockmacd » 27 Oct 2009

Basically on the close of today, initiate a buy stop at today's High + .01. Simple enough, but what ends up happening is the order will get cancelled when the trading session is over. How does one write code to execute a GTC (Good Till Cancel) order ?


[IntrabarOrderGeneration = true]
if (MarketPosition=0 and condition=true and BarStatus(1) = 2 )
then begin
Buy("dv.H") next bar at H+.01 stop;

end;

User avatar
TJ
Posts: 7372
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2105 times

Postby TJ » 27 Oct 2009

You have to enable that in TWS

stockmacd
Posts: 23
Joined: 28 Feb 2007

Postby stockmacd » 27 Oct 2009

Kewl. :D

If anybody wants to know this is how you do it in TWS:

From the menu:
- Page --> Settings
- Presets --> Stocks, Options, etc..
- Settings --> Time in Force

Thanks TJ

stockmacd
Posts: 23
Joined: 28 Feb 2007

Postby stockmacd » 27 Oct 2009

I just tried this out and there's another problem. The trade will work correctly in TWS, however the signal doesn't get triggered in MultiCharts. This will make MC and TWS out of synch, not to mention skew backtesting results.

I've attached an example. It shows 2 instances where the the buy stop didn't get triggered.
Attachments
trailing_buy.jpg
(137.95 KiB) Downloaded 715 times

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

Postby Spaceant » 27 Oct 2009

I don't know whether I understand your strategy fully.

1) To me, your strategy consists of end-of-bar signals. If this is right, you should disable IOG.

2) There is an error on your code, the stop price at H+0.01, H is the current bar's high price. Your code will never issue a signal as price will not be able to be higher than curren bar's high +0.01. You shoud use H[1]+0.01

Hope this help.

Sa

stockmacd
Posts: 23
Joined: 28 Feb 2007

Postby stockmacd » 27 Oct 2009

I want to use IOG b/c I want my stops to be calculated intrabar.

I thought that if you have IOG = true and BarStatus(1)=2, this makes the execution perform on the Closing tick of that bar.

So:

[IntrabarOrderGeneration = true]
if (MarketPosition=0 and condition=true and BarStatus(1) = 2 )
then begin
Buy("dv.H") next bar at H+.01 stop;
end;


It's trying to place a trade for the next bar, which is tomorrow, using the current H + .01 This in theory should work.

User avatar
TJ
Posts: 7372
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2105 times

Postby TJ » 27 Oct 2009

you can test your strategy 24hr/7days a week,
using IB's demo system.

http://www.interactivebrokers.com/en/p. ... entity=llc
click demo --> individual.

no registration required.
it streams day old data (not real time data)

stockmacd
Posts: 23
Joined: 28 Feb 2007

Postby stockmacd » 27 Oct 2009

Thanks TJ. I am using IB's papertrading account to test my strategie. But I can't get MC to do what I want it to do. :lol:

User avatar
TJ
Posts: 7372
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2105 times

Postby TJ » 27 Oct 2009

paper trading account only works during market hours.

use the demo system for testing, you can do it 24/7 !!!


but be careful not to let the demo data overwrite your good data.


Return to “MultiCharts”