# Insidebid-Insideask problem on delta studys

Questions about MultiCharts and user contributed studies.
SP
Posts: 453
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

### Insidebid-Insideask problem on delta studys

All published MD studys use something like this for

Code: Select all

` if Close <= InsideBid then      Bid[Index] = Bid[Index] + MyVol - VolTmpelse if Close >= InsideAsk then      Ask[Index] = Ask[Index] + MyVol - VolTmpelse   begin      // Last tick was between bid/ask      if Close <= LastTick then         Bid[Index] = Bid[Index] + MyVol - VolTmp            else         Ask[Index] = Ask[Index] + MyVol - VolTmp;      end;`

My problem is that the calculation comes after the fact. The video
shows the problem that if a market order of 200 contracts hits the ask
of 59 contracts, the remaining 141 contracts gets the new bid. The studys
claculates this trade as traded at the bid because at the moment of the

Using bid as data2 and close <= c of data2 (instead of insidebid) has the same limitation.
Attachments

Henry MultiСharts
Posts: 9066
Joined: 25 Aug 2011
Has thanked: 1256 times
Been thanked: 2911 times

### Re: Insidebid-Insideask problem on delta studys

Hello SP,

Is the option "Skip identical ticks" disabled in Format->Study->Format study->Properties tab?

SP
Posts: 453
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

### Re: Insidebid-Insideask problem on delta studys

Quote Field is Trade, "Skip identical ticks" is disabled.

It seems that we need a calculation for at bid/ask that is independent from the trade driven calculation of the indicator.

I tried to put the calculation for at bid/ask outside into a function and use RecalcLastbarAfter(.1),
but it doesnt solve the problem.

Code: Select all

`vars: myTicktype (""), price (0),ask(0),bid(0);price = close;ask   = insideask;bid   = insidebid;         if (ask < bid) // should not happen but does         then begin            if (price < ask)       then   myTicktype = "BelowBid"            else if (price = ask)    then   myTicktype = "AtAsk"            else if (price < bid)    then   myTicktype = "BetweenBidAsk"            else if (price = bid)    then   myTicktype = "AtBid"            else                myTicktype = "AboveAsk";         end         else if (bid < ask) //normal case         then begin            if     (price < bid)    then    myTicktype = "BelowBid"            else if (price = bid)    then    myTicktype = "AtBid"            else if (price < ask)    then   myTicktype = "BetweenBidAsk"            else if (price = ask)    then    myTicktype = "AtAsk"            else                myTicktype = "AboveAsk";         end         else //bid==ask, should not happen         begin            if (price < bid)       then    myTicktype = "BelowBid"            else if (price > ask)    then    myTicktype = "AboveAsk"            else                myTicktype = "BetweenBidAsk";         end;tickType = myTicktype ;RecalcLastbarAfter(.1);`

Henry MultiСharts
Posts: 9066
Joined: 25 Aug 2011
Has thanked: 1256 times
Been thanked: 2911 times

### Re: Insidebid-Insideask problem on delta studys

If I understand correctly then you need to return the values before the current trade.
What I can recommend is to add additional data series to the chart (bid(data2) and ask(data3)), and use the previous close value (close of data2[1], close of data3[1]).

Nicolas23
Posts: 50
Joined: 13 Oct 2011
Has thanked: 22 times
Been thanked: 35 times

### Re: Insidebid-Insideask problem on delta studys

Henry,

I know that I am reacting to a message which is a bit old, but I would appreciate a confirmation...

It means that, for the bid and ask received at the same time as a price are the bid & ask in their status following the trade, and not bid & ask just before the trade.

Is my understanding correct?

Nicolas

Henry MultiСharts
Posts: 9066
Joined: 25 Aug 2011
Has thanked: 1256 times
Been thanked: 2911 times

### Re: Insidebid-Insideask problem on delta studys

Nicolas23 wrote:Henry,
I know that I am reacting to a message which is a bit old, but I would appreciate a confirmation...
It means that, for the bid and ask received at the same time as a price are the bid & ask in their status following the trade, and not bid & ask just before the trade.
Is my understanding correct?
Nicolas

Hello Nicolas,

Bid[1] and Ask[1] are referencing to the values before the current trade.
[1] means 1 bar back from the current script calculation bar.
If you need to reference to the current Ask and Bid please use regular Bid and Ask in the code.

Nicolas23
Posts: 50
Joined: 13 Oct 2011
Has thanked: 22 times
Been thanked: 35 times

### Re: Insidebid-Insideask problem on delta studys

Hi Henry,

Actually, my question is a bit different. It relates to the way MultiCharts structures the data.

Let's take a 1-tick chart, and consider
- Close
- Bid
of the last tick.

Close corresponds to the price of the most recent trade. Let's suppose that this trade is on 10 contracts.

But Ask and Bid corresponds to what?
- to ask & bid just before the most recent trade occurred? (before 10 contracts are taken out of the DOM)
- to ask & bid just after the trade occurred? (after 10 contracts have been taken out of the DOM)

Nicolas

Henry MultiСharts
Posts: 9066
Joined: 25 Aug 2011
Has thanked: 1256 times
Been thanked: 2911 times

### Re: Insidebid-Insideask problem on delta studys

Nicolas, which data feed do you use?

Nicolas23
Posts: 50
Joined: 13 Oct 2011
Has thanked: 22 times
Been thanked: 35 times

### Re: Insidebid-Insideask problem on delta studys

Hi Henry,

DTN IQFeed.

Nicolas

Henry MultiСharts
Posts: 9066
Joined: 25 Aug 2011
Has thanked: 1256 times
Been thanked: 2911 times

### Re: Insidebid-Insideask problem on delta studys

Nicolas23 wrote:Hi Henry,

DTN IQFeed.

Nicolas

Hello Nicolas,

The data is structured the way it is sent by the data feed.
IQfeed is sending more ask/bid ticks then trade ticks so they are not alligned.
[Edited] If you want to have the same amount of ask and bid ticks compared to trade ticks-you need to enable the option "Generate a new ask/bid tick if trade changes" in QuoteManager->Tools->Data Sources->IQFeed->Settings.

SP
Posts: 453
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

### Re: Insidebid-Insideask problem on delta studys

Henry Multicharts wrote: If you want your ask and bid ticks to be alligned with trade ticks-you need to enable the option "Generate a new ask/bid tick if trade changes" in QuoteManager->Tools->Data Sources->IQFeed->Settings.

Henry,

i have that option enabled, but if i use a three 1 Tick charts with trade as data1, bid as data2 and ask as data3 and then plot an easy indicator as histogram

Code: Select all

` if barstatus (1) = 2 and barstatus (2)= 2 and barstatus (3) = 2 then plot1 (2); `

it doesnt plot on every bar on realtime bars. So they arent always synchronized, which makes it difficult to reference
past values in realtime.

Henry MultiСharts
Posts: 9066
Joined: 25 Aug 2011
Has thanked: 1256 times
Been thanked: 2911 times

### Re: Insidebid-Insideask problem on delta studys

SP wrote:Henry,

i have that option enabled, but if i use a three 1 Tick charts with trade as data1, bid as data2 and ask as data3 and then plot an easy indicator as histogram

Code: Select all

` if barstatus (1) = 2 and barstatus (2)= 2 and barstatus (3) = 2 then plot1 (2); `

it doesnt plot on every bar on realtime bars. So they arent always synchronized, which makes it difficult to reference
past values in realtime.

I believe there was a misunderstanding. I have edited my post above.

The bars of the different quote fields cannot be aligned on the chart (using non time based resolution) because each tick (with the same hh:mm:ss timestamp) receives unique tick ID. Only data series using the same quote field can be aligned, other solution is to use a time based resolution.

The code you have provided above should plot the histogram properly on 1 second resolution chart.

SP
Posts: 453
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

### Re: Insidebid-Insideask problem on delta studys

Henry,

could Multicharts not simple add one more option to the Quotemanager to retrieve the "AtBidOrAsk" option directly from the IQFeed server like it does
i.e. the QCollector. It is automatically stored if the trade was at bid (b), at ask (a), below bid(d), above ask (e) or between bid and ask (c).

That would solve at least for this datafeed most problems at once which are discussed here for years like the delta calculations, the Cumulative delta and the true
Footprints and many people waste a lot of time with workarounds that didnt work 100 percent.
Attachments
QCollector.jpg (141.14 KiB) Viewed 1288 times

Nick
Posts: 490
Joined: 04 Aug 2006
Has thanked: 4 times
Been thanked: 24 times

### Re: Insidebid-Insideask problem on delta studys

Insidebid and Insideask are not appropriate for this as they return the current value rather than the value at the time the trade occurred (that your are processing). I wrote a couple of the studies that do it like that so am partly to blame I guess!

You can use data1 data2 data3 for last bid ask but that only works for real time data. The problem is that the MC database only stores ticks to 1 second resolution and has no sequence data across multiple data streams. This really makes MC unsuitable for this type of work. I believe that is why interest in it is less at places like Big Mike and fulcrum traders group. These sorts of indicator / analysis are hugely popular. I believe there is a 'kludge' that works with iqfeed that will get the data from their feed but really it needs the MC database sorting out. Incidentally I presume the .net offering uses the same database? I'd be all over that but advanced tools without high precision data aren't any use to me.

Let me say I really like MC or I would not bother topost whenever this topic comes up. Sadly, I just can't use it for a lot of the applications I would like to. I'm not alone, just using 'MD' as an example, there is clearly a massive interest! (there are other applications too) Please TS precision for historical data.

Please TSSupport, I really like MC but just can not use it for half the stuff I want to. Apart from that I am a big supporter.

arnie
Posts: 1593
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 511 times

### Re: Insidebid-Insideask problem on delta studys

Nick wrote:Insidebid and Insideask are not appropriate for this as they return the current value rather than the value at the time the trade occurred (that your are processing). I wrote a couple of the studies that do it like that so am partly to blame I guess!

You can use data1 data2 data3 for last bid ask but that only works for real time data. The problem is that the MC database only stores ticks to 1 second resolution and has no sequence data across multiple data streams. This really makes MC unsuitable for this type of work. I believe that is why interest in it is less at places like Big Mike and fulcrum traders group. These sorts of indicator / analysis are hugely popular. I believe there is a 'kludge' that works with iqfeed that will get the data from their feed but really it needs the MC database sorting out. Incidentally I presume the .net offering uses the same database? I'd be all over that but advanced tools without high precision data aren't any use to me.

Let me say I really like MC or I would not bother topost whenever this topic comes up. Sadly, I just can't use it for a lot of the applications I would like to. I'm not alone, just using 'MD' as an example, there is clearly a massive interest! (there are other applications too) Please TS precision for historical data.

Please TSSupport, I really like MC but just can not use it for half the stuff I want to. Apart from that I am a big supporter.

Since they are going to offer footprint charts and since they need volume at bid and ask so the ladder is correctly calculated, I assume that all the problems that existed in calculating the delta will be solved now.

I'm really thrilled to have this tool in MC.

Nick
Posts: 490
Joined: 04 Aug 2006
Has thanked: 4 times
Been thanked: 24 times

### Re: Insidebid-Insideask problem on delta studys

I missed that announcement Annie, that's great news! Fantastic! I think they must know its a job that has to be done to take MC forward, but I guess messing with the database is quite a significant change. Depending on how the code is written significant need not mean masses of work.

Henry MultiСharts
Posts: 9066
Joined: 25 Aug 2011
Has thanked: 1256 times
Been thanked: 2911 times

### Re: Insidebid-Insideask problem on delta studys

SP wrote:Henry,

could Multicharts not simple add one more option to the Quotemanager to retrieve the "AtBidOrAsk" option directly from the IQFeed server like it does
i.e. the QCollector. It is automatically stored if the trade was at bid (b), at ask (a), below bid(d), above ask (e) or between bid and ask (c).

We do not plan to add such functionality at the moment.
This is not a trivial task and it requres significant changes in currrent implementation of MultiCharts components.

Nick
Posts: 490
Joined: 04 Aug 2006
Has thanked: 4 times
Been thanked: 24 times

### Re: Insidebid-Insideask problem on delta studys

arnie wrote:

Since they are going to offer footprint charts and since they need volume at bid and ask so the ladder is correctly calculated, I assume that all the problems that existed in calculating the delta will be solved now.

I'm really thrilled to have this tool in MC.

Well after a bit of email tag with Andrew I am not quite sure how they plan to implement this. I am still not completely sure they understand what us needed. (proper sequencing of bid ask last historical data).

The last time I successfully explained what was required (i think i did at least)was to Dave probably a couple of years ago. I was optomistic then that it might get done but things just went quiet.

I get the impression database changes arent coming so footprints will either be live only or som kludge to read the data straight off IQFeed servers. I hope I am wrong!!

arnie
Posts: 1593
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 511 times

### Re: Insidebid-Insideask problem on delta studys

For now I'll wait for the beta version.

Too much mix information. One saying that footprint will come to live in 8.1 version and then says that MC requires significant changes to offer such tools which is not planned to be added at the moment.

So I'll just wait for the beta and then we'll discuss what is being offered.

One thing I say, without historical data, footprint usage becomes very limited. Don't forget, one of the biggest advantages of footprint is to have the possibility to replay it and see what was done during the session, inside the bar, at each price. Without historical data we are limited to today's session.

Let's wait and see what will come out.