how to buy / sell on data2  [SOLVED]

Questions about MultiCharts and user contributed studies.
martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

how to buy / sell on data2

Postby martingale » 09 Sep 2012

if I have 2 data for 2 different symbol in my chart and want to buy on data1 and sell on data2, how to do this in PL.

do I write

buy "data1" at market;
sell "data2" at market;

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: how to buy / sell on data2

Postby TJ » 09 Sep 2012

martingale wrote:if I have 2 data for 2 different symbol in my chart and want to buy on data1 and sell on data2, how to do this in PL.

do I write

buy "data1" at market;
sell "data2" at market;

You can only trade on data1.

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 09 Sep 2012

TJ wrote:
martingale wrote:if I have 2 data for 2 different symbol in my chart and want to buy on data1 and sell on data2, how to do this in PL.

do I write

buy "data1" at market;
sell "data2" at market;

You can only trade on data1.


TJ, is there another way to work with spread? can we do that in portfolio backtester?

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: how to buy / sell on data2

Postby TJ » 09 Sep 2012

martingale wrote:
TJ wrote:
martingale wrote:if I have 2 data for 2 different symbol in my chart and want to buy on data1 and sell on data2, how to do this in PL.
do I write
buy "data1" at market;
sell "data2" at market;

You can only trade on data1.

TJ, is there another way to work with spread? can we do that in portfolio backtester?

Please review this Wiki article:
Spread and Pair Trading
https://www.multicharts.com/trading-soft ... ir_Trading

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 09 Sep 2012

interesting walk around, cool.

TJ wrote:Please review this Wiki article:
Spread and Pair Trading
https://www.multicharts.com/trading-soft ... ir_Trading

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 09 Sep 2012

another problem arise from this is bid ask spread.
if we notice 2 ticker has 4 set of data as each has bid, ask.
let's say we long data1 / short data2 at market order
the pair trading strategy will enter the position by long data1 at ask1 and short data2 at bid2, when exit it needs to short data1 at bid1 and long data2 at ask2. when liquidity is a concern, bid/ask spread may not be minimum tick.


User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: how to buy / sell on data2

Postby TJ » 09 Sep 2012

martingale wrote:another problem arise from this is bid ask spread.
if we notice 2 ticker has 4 set of data as each has bid, ask.
let's say we long data1 / short data2 at market order
the pair trading strategy will enter the position by long data1 at ask1 and short data2 at bid2, when exit it needs to short data1 at bid1 and long data2 at ask2. when liquidity is a concern, bid/ask spread may not be minimum tick.

Would that be a MultiCharts deficiency?

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 09 Sep 2012

i think so, surprised to know such a widely used software cant handle spread trading correctly.


TJ wrote:
martingale wrote:another problem arise from this is bid ask spread.
if we notice 2 ticker has 4 set of data as each has bid, ask.
let's say we long data1 / short data2 at market order
the pair trading strategy will enter the position by long data1 at ask1 and short data2 at bid2, when exit it needs to short data1 at bid1 and long data2 at ask2. when liquidity is a concern, bid/ask spread may not be minimum tick.

Would that be a MultiCharts deficiency?

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: how to buy / sell on data2

Postby TJ » 09 Sep 2012

martingale wrote:i think so, surprised to know such a widely used software cant handle spread trading correctly.


Please review and support this project management request:
https://www.multicharts.com/pm/viewissue ... _no=MC-494

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 09 Sep 2012

TJ wrote:
martingale wrote:i think so, surprised to know such a widely used software cant handle spread trading correctly.


Please review and support this project management request:
https://www.multicharts.com/pm/viewissue ... _no=MC-494


voted!

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 10 Sep 2012

could anyone show me how to arrange the data in portfolio backtester for pair trade?
I input the tick data for 2 symbols as in attached snapshot but only first symbol is traded all the time.

does the first line of instrument list means data for signal1 and 2nd line for signal2?
Attachments
pbt.jpg
pbt.jpg (131.14 KiB) Viewed 544 times

User avatar
Henry MultiСharts
Posts: 8503
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2731 times

Re: how to buy / sell on data2  [SOLVED]

Postby Henry MultiСharts » 11 Sep 2012

martingale wrote:could anyone show me how to arrange the data in portfolio backtester for pair trade?
I input the tick data for 2 symbols as in attached snapshot but only first symbol is traded all the time.

does the first line of instrument list means data for signal1 and 2nd line for signal2?

On your screenshot first line of instruments is for strategy 1, second line of instruments is for strategy 2.

Please take a look at the example at this page: Reference other instruments with ease.
If your pair is Google and Microsoft, you would enter GOOG as symbol one and MSFT as symbol two. Then you would add MSFT as data one and GOOG as data two. This way each instrument in the pair is actively referencing the other instrument—and you achieve complete synchronization.

Image
These users thanked the author Henry MultiСharts for the post:
JoshM

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 16 Sep 2012

Henry MultiСharts wrote:
martingale wrote:could anyone show me how to arrange the data in portfolio backtester for pair trade?
I input the tick data for 2 symbols as in attached snapshot but only first symbol is traded all the time.

Image


Henry.

I set up my strategy in the same way as the example,

in each of my signal, I use LinearRegValue to calculate the regression value of the difference of the 2 ticker. they returned me different result. is there possible a bug in the LinearRegValue function in multicharts or there's something I need to take cautious in set up a pair trade strategy?

here is a snapshot of the 2 signal code. in my strategy1, data1 is close of GOOG, data2 is close of MSFT; in strategy2, data1 is close of MSFT, data2 is close of GOOG.

Code: Select all

////signal1
inputs:
   p1(Close of data1),
   p2(Close of data2),

begin
        x = p1 - p2;
        y = LinearRegValue( x, 100, 0 );
      // action...
       ...
       ...

////signal2
inputs:
   p2(Close of data1),
   p1(Close of data2),

begin
        x = p1 - p2;
        y = LinearRegValue( x, 100, 0 );
      // action...
       ...
       ...

User avatar
Henry MultiСharts
Posts: 8503
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2731 times

Re: how to buy / sell on data2

Postby Henry MultiСharts » 17 Sep 2012

Hello Martingale,

Please try the code with the "if symbolname=" addition below:

Code: Select all

////signal1
inputs:
   p1(Close of data1),
   p2(Close of data2),

if symbolname="MSFT" then begin
        x = p1 - p2;
        y = LinearRegValue( x, 100, 0 );
      // action...
       ...
       ...
end;

////signal2
inputs:
   p2(Close of data1),
   p1(Close of data2),

if symbolname="GOOG" then begin
        x = p1 - p2;
        y = LinearRegValue( x, 100, 0 );
      // action...
       ...
       ...
end;

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 17 Sep 2012

Henry MultiСharts wrote:Hello Martingale,

Please try the code with the "if symbolname=" addition below:

Code: Select all

////signal1
inputs:
   p1(Close of data1),
   p2(Close of data2),

if symbolname="MSFT" then begin
        x = p1 - p2;
        y = LinearRegValue( x, 100, 0 );
      // action...
       ...
       ...
end;

////signal2
inputs:
   p2(Close of data1),
   p1(Close of data2),

if symbolname="GOOG" then begin
        x = p1 - p2;
        y = LinearRegValue( x, 100, 0 );
      // action...
       ...
       ...
end;


I tried, the output is the same. why will symbolname help?

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 17 Sep 2012

Henry MultiСharts wrote:Hello Martingale,

Please try the code with the "if symbolname=" addition below:



the problem seems like the each strategy didn't start calculating my LinearRegValue function at the right tick. i.e. I use LinearRegValue(P1,100,0), it should start showing something at 100th tick but it didn't.

i'm confused.

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: how to buy / sell on data2

Postby TJ » 17 Sep 2012

martingale wrote:
Henry MultiСharts wrote:Hello Martingale,

Please try the code with the "if symbolname=" addition below:



the problem seems like the each strategy didn't start calculating my LinearRegValue function at the right tick. i.e. I use LinearRegValue(P1,100,0), it should start showing something at 100th tick but it didn't.

i'm confused.


What is your chart resolution?

100 refers to the 100th bar. Are you using 1 tick bar?

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 17 Sep 2012

TJ wrote:
What is your chart resolution?

100 refers to the 100th bar. Are you using 1 tick bar?


yes, i'm using 1 tick bar. I don't need a chart at all for this. I'm saving the value returned from LinearRegValue into a txt file in my portfolio backtester.

is there a problem with tick level data calculation?

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: how to buy / sell on data2

Postby TJ » 17 Sep 2012

martingale wrote:
TJ wrote:
What is your chart resolution?

100 refers to the 100th bar. Are you using 1 tick bar?


yes, i'm using 1 tick bar. I don't need a chart at all for this. I'm saving the value returned from LinearRegValue into a txt file in my portfolio backtester.




If you don't use a chart for this, how/where do you apply this indicator?

The chart does not have to be visible, but you must load a 1 tick dataseries and apply this indicator specifically to this dataseries. Otherwise the results will not be what you expected.

is there a problem with tick level data calculation?

The computer does not know the difference between a tick and a pip; it is a number, all it knows is to process the number with your designated formula.

martingale
Posts: 79
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to buy / sell on data2

Postby martingale » 17 Sep 2012

TJ wrote:
martingale wrote:
TJ wrote:
What is your chart resolution?

100 refers to the 100th bar. Are you using 1 tick bar?


yes, i'm using 1 tick bar. I don't need a chart at all for this. I'm saving the value returned from LinearRegValue into a txt file in my portfolio backtester.




If you don't use a chart for this, how/where do you apply this indicator?

The chart does not have to be visible, but you must load a 1 tick dataseries and apply this indicator specifically to this dataseries. Otherwise the results will not be what you expected.

is there a problem with tick level data calculation?

The computer does not know the difference between a tick and a pip; it is a number, all it knows is to process the number with your designated formula.


indicator is indicator, signal is signal. if i have a plot function in my study, then it cannot be compiled as a signal, it has to be compiled as indicator. so where is the chart coming from?
confuse, confused.

User avatar
Henry MultiСharts
Posts: 8503
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2731 times

Re: how to buy / sell on data2

Postby Henry MultiСharts » 18 Sep 2012

Martingale, please send me (support@multicharts.com) the following information for futher investigation:
-Workspace you are using
-In QuoteManager select the symbol you are using, make a right click->Export data->Export instrument. Send me the Qmd export file for analysis.
-In Power Language editor->File->Export->export with dependent functions the study you are backtesting. Send me the study export file
- Please attach a detailed problem description and highlight the problem on the screenshots/in the output samples.


Return to “MultiCharts”