sellshort intrabar

Questions about MultiCharts and user contributed studies.
Dug
Posts: 31
Joined: 26 Aug 2009
Location: London

sellshort intrabar

Postby Dug » 17 Dec 2009

Hi, I have been racking my brain - and I think its something obvious that i am missing, but,

am I correct in saying that sellshort CAN ONLY be used on the close of the current bar, or the during the next bar, but it CANNOT be used to trigger to sell intrabar.
Eg; Say I have a trigger that I want to execute when the current bar trades lower than the previous bars low. Then the first instance the trade will be able to be executed is on the close of the current bar.

If so, is there another way of trying IOG or such that I am missing.

I ask as in real life I will sell for a particular move if a new low is taken out, but in testing or just in putting a signal on the chart it always waits until the close.

thanks.

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

Postby TJ » 17 Dec 2009

if you post a snippet of your code...
maybe someone can chime in.

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

Postby TJ » 17 Dec 2009

p.s. do a search here on IOG or IntraBarOrderGeneration.

Dug
Posts: 31
Joined: 26 Aug 2009
Location: London

Postby Dug » 18 Dec 2009

Hi TJ, (sorry I incorrectly assumed it was a simple question - end of a long day)

the simple example code is to backtest an idea - not for live trading.......

......................

Code: Select all

vars: atr(0);

[IntrabarOrderGeneration=True];
if currentbar=1 then begin
cleardebug;
end;

atr=AvgTrueRange(20);

//////////////
condition1 = low<low[1];
condition2= high>high[1];
if condition1 then begin
sellshort this bar on close;
end;

setprofittarget(atr*2);
setstoploss(atr);

/////////////////
print(currentbar,date,"--",atr);
...................................
Basically - I have tried applying this to a daily chart, with IOG turned on, off (upside down, inside out), turned on the bar magnifier, turned it off etc;
I either get a message saying - none of the required data has been obtained, bar magnifier will be disabled.

Or it always shows on the chart that you get set on the close - which is what I have to tell it to do as the earliest time to short.

I dont want to trade off intraday charts - but I do want to see what would happen if during the day you sold when it hit a new low, and not having to wait until the close - before selling after a break of yesterdays low. If it turns out I need 15 years of intraday data to test 15 years of daily data then i guess i'm stuffed.

I understand the logic of backtesting v reality. But if this cant be done then it seems the backtesting cant even get close to replicating reality.

After reading the IOG information - it seemed that this was an issue for a while, and that i thought it was fixed to the extent that it could be done.
Hence it seems I am still missing something.
thanks.

SUPER
Posts: 635
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 81 times

Postby SUPER » 18 Dec 2009

I dont want to trade off intraday charts - but I do want to see what would happen if during the day you sold when it hit a new low, and not having to wait until the close - before selling after a break of yesterdays low. If it turns out I need 15 years of intraday data to test 15 years of daily data then i guess i'm stuffed.
if you want to sell as soon as Low < Low[1] then try using
"sellshort next bar at Market" in your code in realtime it will go short as soon as your condition is meet ( next tick).

You can backtest IOG using BackTest Precision set to 1 tick which will be as close to real trading.(provided you have sufficient tick data)

I ran your sample code on 60 days of daily data without any problems.

IOG has no bugs that I can think of...it is working as expected.
Attachments
MC.png
(25.72 KiB) Downloaded 593 times

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

Postby TJ » 18 Dec 2009

Hi TJ, (sorry I incorrectly assumed it was a simple question - end of a long day)

the simple example code is to backtest an idea - not for live trading.......

...................................
Basically - I have tried applying this to a daily chart, with IOG turned on, off (upside down, inside out), turned on the bar magnifier, turned it off etc;
I either get a message saying - none of the required data has been obtained, bar magnifier will be disabled.

Or it always shows on the chart that you get set on the close - which is what I have to tell it to do as the earliest time to short.

I dont want to trade off intraday charts - but I do want to see what would happen if during the day you sold when it hit a new low, and not having to wait until the close - before selling after a break of yesterdays low. If it turns out I need 15 years of intraday data to test 15 years of daily data then i guess i'm stuffed.

I understand the logic of backtesting v reality. But if this cant be done then it seems the backtesting cant even get close to replicating reality.

After reading the IOG information - it seemed that this was an issue for a while, and that i thought it was fixed to the extent that it could be done.
Hence it seems I am still missing something.
thanks.

you will need tick data in your datastore if you select tick for precision backtesting.

go to QM,

select Edit > Edit Data

see if the symbol has tick data

Dug
Posts: 31
Joined: 26 Aug 2009
Location: London

Postby Dug » 18 Dec 2009

TJ and Super - Thankyou - I tried that and it worked.....on certain contracts

It did not make sense to try that as I would have thought it still is "this bar".
But regardless it works using "next bar" and not "this bar"
also.....

When it comes to IOG - I did not fully understand that it needs the access to the tick data - I thought it assumed that the data traded, and hence you could exit at a breech of yesterdays low (while I know this is technically inaccurate as you dont know when it traded there during the day, and what happened before or after it - I do not really care when trying to test some longer term daily entries _ its part of the slippage).
This seems to be the missing link for me.....hence the error messages, and then QM trying to download data that did not exist.

However my problem still exists :cry:

On running a few more tests the Esginal continuous futures contract data does not work - I think this is because its a made up contract and hence has no tick data (???), The same applied to the ASCII continuous futures contract data I have. As the quote manager cannot download intraday data - then it assumes it does not exist.
It also did not work on some adjusted stock data that I have.
BUT it did work on the 6A H0 - AUDUSD futures contract as I can download the daily data for that.

Hence the problem - that is why the question still remains. (as I said I know its a fudge, but its better to exit and have slippage, than wait until the close, as the slippage is still more realistic than waiting if you are testing off the lows and highs). So if anyone has any ideas of how to do it, other than me taking the trades on the close, and adjusting the prices in excel manually, or buying 15 years of intraday data? they would be much appreciated, OR alternatively as a request to MC to have intrabar order generation "fudged" to assume that you can trade .

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

Postby TJ » 18 Dec 2009

TJ and Super - Thankyou - I tried that and it worked.....on certain contracts

It did not make sense to try that as I would have thought it still is "this bar".
But regardless it works using "next bar" and not "this bar"

see this thread:
http://forum.tssupport.com/viewtopic.php?t=6835


also.....

However my problem still exists :cry:

On running a few more tests the Esginal continuous futures contract data does not work - I think this is because its a made up contract and hence has no tick data (???), The same applied to the ASCII continuous futures contract data I have. As the quote manager cannot download intraday data - then it assumes it does not exist.
It also did not work on some adjusted stock data that I have.
BUT it did work on the 6A H0 - AUDUSD futures contract as I can download the daily data for that.
if I have to test adjusted data...
I would create a dummy symbol and store the adjusted/cleaned data there,
and use the "symbol" for TESTING PURPOSE ONLY.

Hence the problem - that is why the question still remains. (as I said I know its a fudge, but its better to exit and have slippage, than wait until the close, as the slippage is still more realistic than waiting if you are testing off the lows and highs). So if anyone has any ideas of how to do it, other than me taking the trades on the close, and adjusting the prices in excel manually, or buying 15 years of intraday data? they would be much appreciated, OR alternatively as a request to MC to have intrabar order generation "fudged" to assume that you can trade .

in the old days, the LIBB was simulated...
TS had an algorithm to mimic the price oscillation within a price bar.
Maybe this method can be used for limited data testing.


but seriously, you might think you "don't" want to test intraday,
but your concept is intraday,
and your execution will be intraday...
why not just adapt to intraday?

Dug
Posts: 31
Joined: 26 Aug 2009
Location: London

Postby Dug » 20 Dec 2009

thanks, for the info ....

In terms of intraday testing, I understand that it seems in order to be able to trade at any time other than the OHL or C, I would need to do intraday testing.

(When I said I did not want to test intraday I just meant I did not want to test for price bar times of less than daily intervals,) but if the only way to be able to sell at a break of yesterdays low and show in a backtester that the sale was done immediately, it seems I have a few choices -
to have all the intraday data then I guess I will have to search out and buy that - I have the clean daily data I want for 15 years (just not intraday).
- run exports from MC to excel and adjust the prices myself (?)
- request MC to implement a fudge possibility such as the one mentioned via the TS.
Or all of the above.
Thanks for the help guys.


Return to “MultiCharts”