Positive Dependancy

Questions about MultiCharts and user contributed studies.
familytrading
Posts: 33
Joined: 24 Sep 2009
Location: Monterey, CA
Been thanked: 3 times
Contact:

Positive Dependancy

Postby familytrading » 28 Apr 2011

OK, I need a suggestion from the programming "guru's". I want to incorporate positive dependency into my strategy. What I mean by this is to have another indicator or strategy running (I guess it could be in a separate chart but has to be back testable with optimization)
so I was thinking run one on Data 1 and another on Data 2 where Data 1 and Data 2 are both the same X minute charts. Lets say the psuedo strategy is running on data2.

When data 2's strategy has a positionprofit(1) that is < 0 when the new signal arrives, it sends a signal to the data 1 strategy to instead of reverse, just close out position. Data 1 starts up again, when Data 2 has a postionprofit(1) > 0.

Any ideas on how to structure the communications between Data 1 and Data 2 so as they are in synch and I still can optimize on a set of common inputs for both strategies?

Thanks in advance.

Probably pretty simple but I am hung up on how to make the communications from Data 2 to Data 1 seamless.

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Re: Positive Dependancy

Postby TJ » 28 Apr 2011

familytrading wrote:OK, I need a suggestion from the programming "guru's". I want to incorporate positive dependency into my strategy. What I mean by this is to have another indicator or strategy running (I guess it could be in a separate chart but has to be back testable with optimization)
so I was thinking run one on Data 1 and another on Data 2 where Data 1 and Data 2 are both the same X minute charts. Lets say the psuedo strategy is running on data2.

When data 2's strategy has a positionprofit(1) that is < 0 when the new signal arrives, it sends a signal to the data 1 strategy to instead of reverse, just close out position. Data 1 starts up again, when Data 2 has a postionprofit(1) > 0.

Any ideas on how to structure the communications between Data 1 and Data 2 so as they are in synch and I still can optimize on a set of common inputs for both strategies?

Thanks in advance.

Probably pretty simple but I am hung up on how to make the communications from Data 2 to Data 1 seamless.


notes if you are talking about data1 and data2 on the same chart:
You cannot trade on Data2.
Strategies can only execute on Data1.

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Re: Positive Dependancy

Postby TJ » 28 Apr 2011

are data1 and data2 the same instrument?

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Re: Positive Dependancy

Postby TJ » 28 Apr 2011

if you want to pass info between studies and/or charts,
do a search on ADE (All Data Everywhere) and GV (GlobalVariables).

User avatar
furytrader
Posts: 353
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 215 times

Re: Positive Dependancy

Postby furytrader » 28 Apr 2011

The other solution would be to write code that tracks where trading would occur on data set 2 and tells you when you *would* be in a trade (and at what price). The code would then also calculate what the open trade equity would be for that pseudo-position on data set 2, and then uses that information to adjust the behavior of the strategy trading on data set 1. It may sound tricky but actually it's pretty easy by using variables. I've done it before.

familytrading
Posts: 33
Joined: 24 Sep 2009
Location: Monterey, CA
Been thanked: 3 times
Contact:

Re: Positive Dependancy

Postby familytrading » 29 Apr 2011

Thanks,
I am thinking data 1 and data 2 would be the same instrument and time frame in minutes.
You can't use Global variables since they don't work with back testing so i am stuck with the data 1 and data 2.

I will try it out and see how it goes. I assume I can use a variable that will be either a 1 or a 0 to trade or not trade on Data 1.

One thing. If I use data 2, then shouldn't positionprofit(1) of data 2 work???

I will try that first before I have to manually keep track of everything.

Also,

Can't I do things like

mp = marketposition;
mp2 = marketposition of data 2?

I am going to try that but if it doesn't work, then I will just have to keep everything straight manually.

Thanks for the comments.

familytrading
Posts: 33
Joined: 24 Sep 2009
Location: Monterey, CA
Been thanked: 3 times
Contact:

Re: Positive Dependancy

Postby familytrading » 29 Apr 2011

Thanks,
I am thinking data 1 and data 2 would be the same instrument and time frame in minutes.
You can't use Global variables since they don't work with back testing so i am stuck with the data 1 and data 2.

I will try it out and see how it goes. I assume I can use a variable that will be either a 1 or a 0 to trade or not trade on Data 1.

One thing. If I use data 2, then shouldn't positionprofit(1) of data 2 work???

I will try that first before I have to manually keep track of everything.

Also,

Can't I do things like

mp = marketposition;
mp2 = marketposition of data 2?

I am going to try that but if it doesn't work, then I will just have to keep everything straight manually.

Thanks for the comments.

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Re: Positive Dependancy

Postby TJ » 29 Apr 2011

familytrading wrote:Thanks,
I am thinking data 1 and data 2 would be the same instrument and time frame in minutes.
You can't use Global variables since they don't work with back testing so i am stuck with the data 1 and data 2.

I will try it out and see how it goes. I assume I can use a variable that will be either a 1 or a 0 to trade or not trade on Data 1.

One thing. If I use data 2, then shouldn't positionprofit(1) of data 2 work???

I will try that first before I have to manually keep track of everything.

Also,

Can't I do things like

mp = marketposition;
mp2 = marketposition of data 2?

I am going to try that but if it doesn't work, then I will just have to keep everything straight manually.

Thanks for the comments.



You mean you are trying to go LONG and SHORT of the same instrument at the same time?

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Re: Positive Dependancy

Postby TJ » 29 Apr 2011

let's get the terminology on the same page...

if you have 2 data series on the same chart,
we refer to them as data1 and data2.

if you have 2 data series on separate charts,
we refer to them as chart1 and chart2.

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

Re: Positive Dependancy

Postby Spaceant » 29 Apr 2011

furytrader wrote:The other solution would be to write code that tracks where trading would occur on data set 2 and tells you when you *would* be in a trade (and at what price). The code would then also calculate what the open trade equity would be for that pseudo-position on data set 2, and then uses that information to adjust the behavior of the strategy trading on data set 1. It may sound tricky but actually it's pretty easy by using variables. I've done it before.


Did you use ADE or other tool(s) for this?

Sa

User avatar
furytrader
Posts: 353
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 215 times

Re: Positive Dependancy

Postby furytrader » 29 Apr 2011

What I did was mimic the system logic on data2 and then track whether these trading rules would've been long, short, etc. So, in pseudo-code, it would be something like:

If Average(C of data2,20) Crosses Above Average(C of data2,40) Then vPosition = 1;

... where vPosition is simply a regular variable. At this point, you could also save as a variable the price at which the trading rules on data2 would've gotten long, and then when the exit rule for data2 is signalled, you could calculate the P&L for that "trade" based on the price where the trading rules would've exited data2, etc.

In sum, in the signal (system code) that is used for Data 1, you would embed the trading logic for the trading rules that would be applied to data2 and then instead of saying "Buy Next Bar On Open of Data2", you'd say something like "vEntryPrice = Close of data2" ... based on the values of those variables, you could then adjust the trading logic that is used to trade data1.

I know this probably sounds confusing, so if this isn't clear, let me know.

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Re: Positive Dependancy

Postby TJ » 29 Apr 2011

furytrader wrote:...
I know this probably sounds confusing, so if this isn't clear, let me know.


No, not confusing at all. As a matter of fact, this is the way it should be done.

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Re: Positive Dependancy

Postby TJ » 29 Apr 2011

furytrader wrote:...

If Average(C of data2,20) Crosses Above Average(C of data2,40) Then vPosition = 1;
....



side note:

Average(C of data2,20)

should be written as

Average(C, 20) of data2

familytrading
Posts: 33
Joined: 24 Sep 2009
Location: Monterey, CA
Been thanked: 3 times
Contact:

Re: Positive Dependancy

Postby familytrading » 29 Apr 2011

Thanks for the clarification. By the way what furytrader wrote is what I am trying to accomplish. My issue is not with just one trade, but I use pyramiding in the algorithm. I guess I should start with one contract, get it working and then move onto subsequent trading.

Just started out trying to do it all first, and got hung up in arrays and transferring of flags and info between each of the data series.

Back to the beginning and only do it for the first signal and see if I can get it done. If I have any more issues, I will post.

By the way, you can't use marketposition or any like key words when referring to data 2.

Instructions like positionprofit data2 do not compile. It would have been so much easier if this capability was there.

Key words like

Positionprofit
marketposition
currentcontracts

if they could be set up as marketposition data2 then this would be much easier.

Thanks again for your assistance. I will post back when I finally get this completed. I am learning while I am doing.

Obviously not a programmer by training.


Return to “MultiCharts”