Transfer Data between charts

Questions about MultiCharts and user contributed studies.
dblend
Posts: 16
Joined: 11 Jul 2011
Been thanked: 1 time

Transfer Data between charts

Postby dblend » 11 Jul 2011

Hi,

I am new to this forum and have searched for help with this issue, found some useful threads but would still like additional help.

I am designing a simple strategy which uses two instruments on 2 separate charts; I need to send the net volume traded for each instrument to the other chart.

Based on my research I can use GlobalVariables or ADE to achieve this. Having watched the following tutorial:
http://www.markplex.com/tutorial36-usin ... s-data.php
I encounter the same problem:
Suppose each chart is a 30 second chart, using Global variable I have no way to know if the data was sent or received first between the two different charts. Markplex suggest a work around of using a delay in the code to ensure the latest values are received before the calculations are performed.

I am hesitant to use delays in code as i am not sure how this will affect sending/cancelling of orders etc.

Is there an alternative solution, like using intrabarordergeneration or intrabarpersist that will allow me to send and receive the global variable every tick instead of once every 30 seconds (I don’t mind the variable being 1 tick off, not 30 seconds) and is this a viable option considering the increase in CPU usage.

If someone has any other solutions to what I imagine is a very common problem, i would greatly appreciate them.

Regards,

Darren Blend

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: Transfer Data between charts

Postby Stan Bokov » 11 Jul 2011

Here is our input:

1. SetPeg - Quote from EL guide "SetPeg is an advanced order feature of the ECN’s that allows you to place a dynamic limit order that always stays on the best bid or best ask up or down to a set limit amount. The SetPeg order can be placed to peg to the best bid/ask or a midpoint between the bid and ask. If the market moves, your order is automatically canceled
and moved to the new best bid or ask."

You can achieve this with MultiCharts simply within your code – always place your limit order at best ask or best bid, or the midpoint by doing the calculation (currentask – currentbid) / 2 and placing your order there. Turn on IntrabarOrderGeneration so on each tick you will keep current. Effect is the same, plus we don’t cancel (like Setpeg is described) but we modify the order so you don’t lose your place in the queue. If it’s always cancelled you’ll have troubles getting filled because you’ll be going to the back of the line, so I’m not even sure how you’d use this SetPeg.

2.SetShowOnly – seems useful, but this is not available in MC. Some traders use scaling in and scaling out, so that you don’t move the market – and get filled.
I am hesitant to put a delay in code as i feel this is not a great solution and also i am not sure how orders will be treated/cancelled amended with a delay in the code?
We don’t recommend adding any delays into your code, especially since it won’t help much in this situation.

You should turn on IntrabarOrderGeneration, because then GV values will be updated on every tick. Intrabarpersist is not needed in this case. You can use the keyword RecalcLastbarAfter(30), which will force your script to recalculate every 30 seconds.

dblend
Posts: 16
Joined: 11 Jul 2011
Been thanked: 1 time

Re: Transfer Data between charts

Postby dblend » 11 Jul 2011

You can achieve this with MultiCharts simply within your code – always place your limit order at best ask or best bid, or the midpoint by doing the calculation (currentask – currentbid) / 2 and placing your order there. Turn on IntrabarOrderGeneration so on each tick you will keep current. Effect is the same, plus we don’t cancel (like Setpeg is described) but we modify the order so you don’t lose your place in the queue. If it’s always cancelled you’ll have troubles getting filled because you’ll be going to the back of the line, so I’m not even sure how you’d use this SetPeg.
Thanks for the prompt answer. I will take your advice surrounding point 2.
To go back to point one, which i asked about pegging an order to either best bid/ask or best bid+offset/ask-offset or midprice. the problem i see with this for the bid/offer +/-offset and midprice pegs and using intrabarordergeneration is when a trade is placed, the new order becomes the new best bid (or offer is selling) and this will create a new tick and then then the next trade will want to be placed above itself, so for example say we wish to peg at mid of bid 80 and offer 100, the limit price will be placed at 90, this will cause a new tick and the condition will be evaluated now with bid 90 offer 100 and the order will be ammended to 95 etc.

Does MC have a way of avoiding this scenario or is there a workaround?

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: Transfer Data between charts

Postby Stan Bokov » 12 Jul 2011

I asked about pegging an order to either best bid/ask or best bid+offset/ask-offset or midprice. the problem i see with this for the bid/offer +/-offset and midprice pegs and using intrabarordergeneration is when a trade is placed, the new order becomes the new best bid (or offer is selling) and this will create a new tick
New ticks aren't created by MC, so I don't understand the logic here. We recalculate the script based on new ticks received.
and then then the next trade will want to be placed above itself, so for example say we wish to peg at mid of bid 80 and offer 100, the limit price will be placed at 90, this will cause a new tick and the condition will be evaluated now with bid 90 offer 100 and the order will be ammended to 95 etc.
I don't envision the scenario happening at all. Ask ticks and bid ticks are read as they arrive, and the orders are placed accordingly.

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

Re: Transfer Data between charts

Postby furytrader » 12 Jul 2011

"... and then then the next trade will want to be placed above itself, so for example say we wish to peg at mid of bid 80 and offer 100, the limit price will be placed at 90, this will cause a new tick and the condition will be evaluated now with bid 90 offer 100 and the order will be ammended to 95 etc."
In order to avoid a self-perpetuating cycle of the type you described, you would want to verify the level at which the new bid and asks are coming in and compare them to where you're already working your bid or offer. If they are at the level at which you're already working your order, you would program your model to not do anything.

So, for example, if the offer is 100 and the bid is 80 and you're not working any orders right now, your bid would be at 90 (assuming you wanted to get long). When you place that order, the fact that you placed a bid at 90 would cause the exchange to notify the market that this happened - causing a new bid to be transmitted in the datastream.

You would want to check whether the new bid is coming in at the level at which you entered your own order so that you don't update your bid in reference to your own, earlier bid. The logic seems pretty straightforward.

dblend
Posts: 16
Joined: 11 Jul 2011
Been thanked: 1 time

Re: Transfer Data between charts

Postby dblend » 12 Jul 2011

Thank you furytrader that makes sense.
My question was originally in response to reading about Advanced Order Automation in EasyLanguage pg. 94 EasyLanguage Essentials, where they speak of SetPeg, SetShowOnly etc functions, that basically allow the system to manage peg orders like the types we have previously spoken about and iceberg orders etc.

Based on my understanding from Stan and yourself, we can achieve through clever logic and intrabarordergeneration.


Return to “MultiCharts”