MD code not working
MD code not working
Hi everyone,
I found this indicator for TS and I tried to import it, but it doesn't work. I don't know how to use PowerLanguage, so I'm asking for help. Anyone wanna take a shot at fixing it?
Thanks in advance!
code starts here
-----------------------------
inputs:
Threshold1( 150 ),
Threshold2( 300 ),
Threshold3( 600 ),
DisplayDelta( false ),
Type( 1 ), // 1 = Use Upticks/Downticks, 2 = Use Bid/Ask
BidAskArraySz( 1000 );
variables:
TickSize( MinMove / PriceScale ),
PriceAtIndex( Open ),
BaseIndex( BidAskArraySz/2 ),
Red1(RGB(255,185,185)),
Red2(RGB(255,128,128)),
Red3(RGB(255,0,0)),
Red4(RGB(128,0,0)),
Green1(RGB(210,255,210)),
Green2(RGB(125,255,125)),
Green3(RGB(0,255,0)),
Green4(RGB(0,128,0)),
i( 0 );
variables:
intrabarpersist Price( 0 ),
intrabarpersist MyVol( 0 ),
intrabarpersist VolTmp( 0 ),
intrabarpersist LastTick( 0 ),
intrabarpersist MyCurrentBar( 0 ),
intrabarpersist Index( 0 ),
intrabarpersist BidAskDelta( 0 ),
intrabarpersist xDelta( 0 ),
intrabarpersist TextString(""),
intrabarpersist MyUpTicks( 0 ),
intrabarpersist MyDownTicks( 0 );
Arrays:
intrabarpersist Bid[](0),
intrabarpersist Ask[](0);
Array_SetMaxIndex( Bid, BidAskArraySz );
Array_SetMaxIndex( Ask, BidAskArraySz );
if (Type = 1 or Type = 2) and LastBarOnChart and BarType < 2 then
begin
MyVol = Ticks;
PriceAtIndex = Open;
if CurrentBar > MyCurrentBar then
begin
VolTmp = 0;
MyCurrentBar = CurrentBar;
MyUpTicks = 0;
MyDownTicks = 0;
for i = 0 to BidAskArraySz - 1
begin
Bid = 0;
Ask = 0;
end;
end;
Index = BaseIndex + (Close - PriceAtIndex) / TickSize;
if InsideBid < InsideAsk then
begin
if Type = 1 then
begin
// Use Upticks/Downticks
if DownTicks <> MyDownTicks then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if UpTicks <> MyUpTicks then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
begin
if Close <= LastTick then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else
Ask[Index] = Ask[Index] + MyVol - VolTmp;
end;
end
else
begin
// Use Bid/Ask
// Warning: TS provides snapshot of bid/ask
if Close <= InsideBid then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if Close >= InsideAsk then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
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;
end;
end;
MyUpTicks = UpTicks;
MyDownTicks = DownTicks;
VolTmp = MyVol;
LastTick = Close;
xDelta = 0;
Price = Low;
while Price <= High
begin
Index = BaseIndex + (Price - PriceAtIndex) / TickSize;
TextString = NumToStr(Bid[Index],0) + " x " + NumToStr(Ask[Index],0);
Value99 = Text_New(Date, Time, 0, " ");
Text_SetString(Value99, TextString);
Text_SetLocation(Value99, Date, Time, Price);
Text_SetStyle(Value99, 1, 1);
BidAskDelta = Ask[Index] - Bid[Index];
if BidAskDelta > Threshold3 then
Text_SetColor(Value99, Green4)
else if BidAskDelta > Threshold2 then
Text_SetColor(Value99, Green3)
else if BidAskDelta > Threshold1 then
Text_SetColor(Value99, Green2)
else if BidAskDelta >= 0 then
Text_SetColor(Value99, Green1)
else if BidAskDelta < -Threshold3 then
Text_SetColor(Value99, Red4)
else if BidAskDelta < -Threshold2 then
Text_SetColor(Value99, Red3)
else if BidAskDelta < -Threshold1 then
Text_SetColor(Value99, Red2)
else
Text_SetColor(Value99, Red1);
xDelta = xDelta + BidAskDelta;
Price = Price + TickSize;
end;
if DisplayDelta = true then
begin
Value99 = Text_New(Date, Time, 0, " ");
Text_SetString(Value99, NumToStr(xDelta, 0 ));
Text_SetLocation(Value99, Date, Time, Low - TickSize);
Text_SetStyle(Value99, 1, 1);
if xDelta >= 0 then
Text_SetColor(Value99, Green)
else
Text_SetColor(Value99, Red);
end;
end;
-----------------------
code ends here
I found this indicator for TS and I tried to import it, but it doesn't work. I don't know how to use PowerLanguage, so I'm asking for help. Anyone wanna take a shot at fixing it?
Thanks in advance!
code starts here
-----------------------------
inputs:
Threshold1( 150 ),
Threshold2( 300 ),
Threshold3( 600 ),
DisplayDelta( false ),
Type( 1 ), // 1 = Use Upticks/Downticks, 2 = Use Bid/Ask
BidAskArraySz( 1000 );
variables:
TickSize( MinMove / PriceScale ),
PriceAtIndex( Open ),
BaseIndex( BidAskArraySz/2 ),
Red1(RGB(255,185,185)),
Red2(RGB(255,128,128)),
Red3(RGB(255,0,0)),
Red4(RGB(128,0,0)),
Green1(RGB(210,255,210)),
Green2(RGB(125,255,125)),
Green3(RGB(0,255,0)),
Green4(RGB(0,128,0)),
i( 0 );
variables:
intrabarpersist Price( 0 ),
intrabarpersist MyVol( 0 ),
intrabarpersist VolTmp( 0 ),
intrabarpersist LastTick( 0 ),
intrabarpersist MyCurrentBar( 0 ),
intrabarpersist Index( 0 ),
intrabarpersist BidAskDelta( 0 ),
intrabarpersist xDelta( 0 ),
intrabarpersist TextString(""),
intrabarpersist MyUpTicks( 0 ),
intrabarpersist MyDownTicks( 0 );
Arrays:
intrabarpersist Bid[](0),
intrabarpersist Ask[](0);
Array_SetMaxIndex( Bid, BidAskArraySz );
Array_SetMaxIndex( Ask, BidAskArraySz );
if (Type = 1 or Type = 2) and LastBarOnChart and BarType < 2 then
begin
MyVol = Ticks;
PriceAtIndex = Open;
if CurrentBar > MyCurrentBar then
begin
VolTmp = 0;
MyCurrentBar = CurrentBar;
MyUpTicks = 0;
MyDownTicks = 0;
for i = 0 to BidAskArraySz - 1
begin
Bid = 0;
Ask = 0;
end;
end;
Index = BaseIndex + (Close - PriceAtIndex) / TickSize;
if InsideBid < InsideAsk then
begin
if Type = 1 then
begin
// Use Upticks/Downticks
if DownTicks <> MyDownTicks then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if UpTicks <> MyUpTicks then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
begin
if Close <= LastTick then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else
Ask[Index] = Ask[Index] + MyVol - VolTmp;
end;
end
else
begin
// Use Bid/Ask
// Warning: TS provides snapshot of bid/ask
if Close <= InsideBid then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if Close >= InsideAsk then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
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;
end;
end;
MyUpTicks = UpTicks;
MyDownTicks = DownTicks;
VolTmp = MyVol;
LastTick = Close;
xDelta = 0;
Price = Low;
while Price <= High
begin
Index = BaseIndex + (Price - PriceAtIndex) / TickSize;
TextString = NumToStr(Bid[Index],0) + " x " + NumToStr(Ask[Index],0);
Value99 = Text_New(Date, Time, 0, " ");
Text_SetString(Value99, TextString);
Text_SetLocation(Value99, Date, Time, Price);
Text_SetStyle(Value99, 1, 1);
BidAskDelta = Ask[Index] - Bid[Index];
if BidAskDelta > Threshold3 then
Text_SetColor(Value99, Green4)
else if BidAskDelta > Threshold2 then
Text_SetColor(Value99, Green3)
else if BidAskDelta > Threshold1 then
Text_SetColor(Value99, Green2)
else if BidAskDelta >= 0 then
Text_SetColor(Value99, Green1)
else if BidAskDelta < -Threshold3 then
Text_SetColor(Value99, Red4)
else if BidAskDelta < -Threshold2 then
Text_SetColor(Value99, Red3)
else if BidAskDelta < -Threshold1 then
Text_SetColor(Value99, Red2)
else
Text_SetColor(Value99, Red1);
xDelta = xDelta + BidAskDelta;
Price = Price + TickSize;
end;
if DisplayDelta = true then
begin
Value99 = Text_New(Date, Time, 0, " ");
Text_SetString(Value99, NumToStr(xDelta, 0 ));
Text_SetLocation(Value99, Date, Time, Low - TickSize);
Text_SetStyle(Value99, 1, 1);
if xDelta >= 0 then
Text_SetColor(Value99, Green)
else
Text_SetColor(Value99, Red);
end;
end;
-----------------------
code ends here
- Alex Kramer
- Posts: 834
- Joined: 23 Feb 2006
Sorry, correcting
We fixed the code, now it complies without errors:
inputs:
Threshold1( 150 ),
Threshold2( 300 ),
Threshold3( 600 ),
DisplayDelta( false ),
Type( 1 ), // 1 = Use Upticks/Downticks, 2 = Use Bid/Ask
BidAskArraySz( 1000 );
variables:
TickSize( MinMove / PriceScale ),
PriceAtIndex( Open ),
BaseIndex( BidAskArraySz/2 ),
Red1(RGB(255,185,185)),
Red2(RGB(255,128,128)),
Red3(RGB(255,0,0)),
Red4(RGB(128,0,0)),
Green1(RGB(210,255,210)),
Green2(RGB(125,255,125)),
Green3(RGB(0,255,0)),
Green4(RGB(0,128,0)),
ii( 0 );
variables:
intrabarpersist Price( 0 ),
intrabarpersist MyVol( 0 ),
intrabarpersist VolTmp( 0 ),
intrabarpersist LastTick( 0 ),
intrabarpersist MyCurrentBar( 0 ),
intrabarpersist Index( 0 ),
intrabarpersist BidAskDelta( 0 ),
intrabarpersist xDelta( 0 ),
intrabarpersist TextString(""),
intrabarpersist MyUpTicks( 0 ),
intrabarpersist MyDownTicks( 0 );
Arrays:
intrabarpersist Bid[](0),
intrabarpersist Ask[](0);
Array_SetMaxIndex( Bid, BidAskArraySz );
Array_SetMaxIndex( Ask, BidAskArraySz );
if (Type = 1 or Type = 2) and LastBarOnChart and BarType < 2 then
begin
MyVol = Ticks;
PriceAtIndex = Open;
if CurrentBar > MyCurrentBar then
begin
VolTmp = 0;
MyCurrentBar = CurrentBar;
MyUpTicks = 0;
MyDownTicks = 0;
for ii = 0 to BidAskArraySz - 1
begin
Bid[ii] = 0;
Ask[ii] = 0;
end;
end;
Index = BaseIndex + (Close - PriceAtIndex) / TickSize;
if InsideBid < InsideAsk then
begin
if Type = 1 then
begin
// Use Upticks/Downticks
if DownTicks <> MyDownTicks then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if UpTicks <> MyUpTicks then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
begin
if Close <= LastTick then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else
Ask[Index] = Ask[Index] + MyVol - VolTmp;
end;
end
else
begin
// Use Bid/Ask
// Warning: TS provides snapshot of bid/ask
if Close <= InsideBid then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if Close >= InsideAsk then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
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;
end;
end;
MyUpTicks = UpTicks;
MyDownTicks = DownTicks;
VolTmp = MyVol;
LastTick = Close;
xDelta = 0;
Price = Low;
while Price <= High
begin
Index = BaseIndex + (Price - PriceAtIndex) / TickSize;
TextString = NumToStr(Bid[Index],0) + " x " + NumToStr(Ask[Index],0);
Value99 = Text_New(Date, Time, 0, " ");
Text_SetString(Value99, TextString);
Text_SetLocation(Value99, Date, Time, Price);
Text_SetStyle(Value99, 1, 1);
BidAskDelta = Ask[Index] - Bid[Index];
if BidAskDelta > Threshold3 then
Text_SetColor(Value99, Green4)
else if BidAskDelta > Threshold2 then
Text_SetColor(Value99, Green3)
else if BidAskDelta > Threshold1 then
Text_SetColor(Value99, Green2)
else if BidAskDelta >= 0 then
Text_SetColor(Value99, Green1)
else if BidAskDelta < -Threshold3 then
Text_SetColor(Value99, Red4)
else if BidAskDelta < -Threshold2 then
Text_SetColor(Value99, Red3)
else if BidAskDelta < -Threshold1 then
Text_SetColor(Value99, Red2)
else
Text_SetColor(Value99, Red1);
xDelta = xDelta + BidAskDelta;
Price = Price + TickSize;
end;
if DisplayDelta = true then
begin
Value99 = Text_New(Date, Time, 0, " ");
Text_SetString(Value99, NumToStr(xDelta, 0 ));
Text_SetLocation(Value99, Date, Time, Low - TickSize);
Text_SetStyle(Value99, 1, 1);
if xDelta >= 0 then
Text_SetColor(Value99, Green)
else
Text_SetColor(Value99, Red);
end;
end;
inputs:
Threshold1( 150 ),
Threshold2( 300 ),
Threshold3( 600 ),
DisplayDelta( false ),
Type( 1 ), // 1 = Use Upticks/Downticks, 2 = Use Bid/Ask
BidAskArraySz( 1000 );
variables:
TickSize( MinMove / PriceScale ),
PriceAtIndex( Open ),
BaseIndex( BidAskArraySz/2 ),
Red1(RGB(255,185,185)),
Red2(RGB(255,128,128)),
Red3(RGB(255,0,0)),
Red4(RGB(128,0,0)),
Green1(RGB(210,255,210)),
Green2(RGB(125,255,125)),
Green3(RGB(0,255,0)),
Green4(RGB(0,128,0)),
ii( 0 );
variables:
intrabarpersist Price( 0 ),
intrabarpersist MyVol( 0 ),
intrabarpersist VolTmp( 0 ),
intrabarpersist LastTick( 0 ),
intrabarpersist MyCurrentBar( 0 ),
intrabarpersist Index( 0 ),
intrabarpersist BidAskDelta( 0 ),
intrabarpersist xDelta( 0 ),
intrabarpersist TextString(""),
intrabarpersist MyUpTicks( 0 ),
intrabarpersist MyDownTicks( 0 );
Arrays:
intrabarpersist Bid[](0),
intrabarpersist Ask[](0);
Array_SetMaxIndex( Bid, BidAskArraySz );
Array_SetMaxIndex( Ask, BidAskArraySz );
if (Type = 1 or Type = 2) and LastBarOnChart and BarType < 2 then
begin
MyVol = Ticks;
PriceAtIndex = Open;
if CurrentBar > MyCurrentBar then
begin
VolTmp = 0;
MyCurrentBar = CurrentBar;
MyUpTicks = 0;
MyDownTicks = 0;
for ii = 0 to BidAskArraySz - 1
begin
Bid[ii] = 0;
Ask[ii] = 0;
end;
end;
Index = BaseIndex + (Close - PriceAtIndex) / TickSize;
if InsideBid < InsideAsk then
begin
if Type = 1 then
begin
// Use Upticks/Downticks
if DownTicks <> MyDownTicks then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if UpTicks <> MyUpTicks then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
begin
if Close <= LastTick then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else
Ask[Index] = Ask[Index] + MyVol - VolTmp;
end;
end
else
begin
// Use Bid/Ask
// Warning: TS provides snapshot of bid/ask
if Close <= InsideBid then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if Close >= InsideAsk then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
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;
end;
end;
MyUpTicks = UpTicks;
MyDownTicks = DownTicks;
VolTmp = MyVol;
LastTick = Close;
xDelta = 0;
Price = Low;
while Price <= High
begin
Index = BaseIndex + (Price - PriceAtIndex) / TickSize;
TextString = NumToStr(Bid[Index],0) + " x " + NumToStr(Ask[Index],0);
Value99 = Text_New(Date, Time, 0, " ");
Text_SetString(Value99, TextString);
Text_SetLocation(Value99, Date, Time, Price);
Text_SetStyle(Value99, 1, 1);
BidAskDelta = Ask[Index] - Bid[Index];
if BidAskDelta > Threshold3 then
Text_SetColor(Value99, Green4)
else if BidAskDelta > Threshold2 then
Text_SetColor(Value99, Green3)
else if BidAskDelta > Threshold1 then
Text_SetColor(Value99, Green2)
else if BidAskDelta >= 0 then
Text_SetColor(Value99, Green1)
else if BidAskDelta < -Threshold3 then
Text_SetColor(Value99, Red4)
else if BidAskDelta < -Threshold2 then
Text_SetColor(Value99, Red3)
else if BidAskDelta < -Threshold1 then
Text_SetColor(Value99, Red2)
else
Text_SetColor(Value99, Red1);
xDelta = xDelta + BidAskDelta;
Price = Price + TickSize;
end;
if DisplayDelta = true then
begin
Value99 = Text_New(Date, Time, 0, " ");
Text_SetString(Value99, NumToStr(xDelta, 0 ));
Text_SetLocation(Value99, Date, Time, Low - TickSize);
Text_SetStyle(Value99, 1, 1);
if xDelta >= 0 then
Text_SetColor(Value99, Green)
else
Text_SetColor(Value99, Red);
end;
end;
- Alex Kramer
- Posts: 834
- Joined: 23 Feb 2006
Hi Server,
Might I ask where you got the code...it goes a bit further than mine - colouring based on a threshold. I was interested if there was a discussion that went along with it?
I am not sure why the bid ask is held in array - dosent seem neccassary as things are. I guess that at some stage it was going to save the array so disc so when you load TS/MC you can read the last 1000 bid ask values. I am not sure.
It would be great if MC had an option of 'playing' every tickof every data series into a worksheet so indicators like this would load on startup. Something like a competitors TickPrecise technology. I guess that should go in the suggestions thread.
Cheers,
Nick.
Might I ask where you got the code...it goes a bit further than mine - colouring based on a threshold. I was interested if there was a discussion that went along with it?
I am not sure why the bid ask is held in array - dosent seem neccassary as things are. I guess that at some stage it was going to save the array so disc so when you load TS/MC you can read the last 1000 bid ask values. I am not sure.
It would be great if MC had an option of 'playing' every tickof every data series into a worksheet so indicators like this would load on startup. Something like a competitors TickPrecise technology. I guess that should go in the suggestions thread.
Cheers,
Nick.
- Alex Kramer
- Posts: 834
- Joined: 23 Feb 2006
Hi Alex,
Its kind of hard to explain. The code only displays the delta study from when multicharts starts, even if you have full bid ask last history in the database. To get it to calculate correctly for historical data you would need to 'send each tick into the chart' when the chart loads.
Let me try from a differetn angle. What the code does is take the volume of each tick and calculate if its on the bid or ask. It then either adds or subtracts it from the overall delta. You might see how this wont work currently for historical data?
Cheers,
Nick.
Its kind of hard to explain. The code only displays the delta study from when multicharts starts, even if you have full bid ask last history in the database. To get it to calculate correctly for historical data you would need to 'send each tick into the chart' when the chart loads.
Let me try from a differetn angle. What the code does is take the volume of each tick and calculate if its on the bid or ask. It then either adds or subtracts it from the overall delta. You might see how this wont work currently for historical data?
Cheers,
Nick.
- Alex Kramer
- Posts: 834
- Joined: 23 Feb 2006
Quick question regarding price scale....
If I set it to 1/4 in the QM window, I get the price displayed with only one decimal point for the ES and rounded up: 1360.75 -> 1360.8 can someone explain to me how should the QM/Window for ES be configured to both have the correct Minimal Movement / Price Scale and Display Settings?
If I set it to 1/4 in the QM window, I get the price displayed with only one decimal point for the ES and rounded up: 1360.75 -> 1360.8 can someone explain to me how should the QM/Window for ES be configured to both have the correct Minimal Movement / Price Scale and Display Settings?
- Alex Kramer
- Posts: 834
- Joined: 23 Feb 2006
Please refrain from using fractions in the Price Scale; this is a feature meant specifically for the few instruments traded in fractional, not decimal prices, and this has not yet been implemented completely.
So applying 1/4, 1/32 or other fractional scale to a usual ES symbol is likely to give you all kinds of worries and no reliable pricing.
So applying 1/4, 1/32 or other fractional scale to a usual ES symbol is likely to give you all kinds of worries and no reliable pricing.
- Alex Kramer
- Posts: 834
- Joined: 23 Feb 2006
Well...the scaling works fine but the code doesnt work. If a new bar starts it counts correct until the price within that bar changes or the trade at the ask is followed from a "bid-trade". Then every number for this bar goes to 0. I assume it has to do with the unability to get the last size of the trade right: I tried this simple code that should provide the size/volume of the last trade but it doesnt:
*********
variables: intrabarpersist prev_volume(0);
value1=ticks;
plot1(prev_volume-value1, "TradeSize", blue);
prev_volume=value1;
*************
And I guess if this doesnt work the MD-Code cannot work correct.
As already said I am using the stable version of MC together with IB. Has anybody the same problem or is somebody any idea why the MD code does not work?
*********
variables: intrabarpersist prev_volume(0);
value1=ticks;
plot1(prev_volume-value1, "TradeSize", blue);
prev_volume=value1;
*************
And I guess if this doesnt work the MD-Code cannot work correct.
As already said I am using the stable version of MC together with IB. Has anybody the same problem or is somebody any idea why the MD code does not work?
To be more specific: If price changes the line at the previous price turns to 0x0 and the line with the last price is showing the complete volume for that bar, color coded and displayed on the bid or ask-side depending on wich side that last trade was.
So if the bar is finished I have some 0x0 lines, 1 line with the complete volume for that bar (i.e. 115x0) and a delta value showing the volume (i.e. 115).
So if the bar is finished I have some 0x0 lines, 1 line with the complete volume for that bar (i.e. 115x0) and a delta value showing the volume (i.e. 115).
@guest2
This is what i get for the FDAX with IB-Data.
I only get 0x0 lines in fast markets when IB sends only snapshot data, not the true sales.
Do you use 1 or 2 for the input "Type"?
This is what i get for the FDAX with IB-Data.
I only get 0x0 lines in fast markets when IB sends only snapshot data, not the true sales.
Do you use 1 or 2 for the input "Type"?
- Attachments
-
- MD2.png
- (75.1 KiB) Downloaded 3518 times
changed from guest2 to my login-name so I hope I can attach files...
okay, so if it works for you it is not an issue with IB. But as described I get just 0x0 lines with sometimes 1 line showing the complete volume for that bar. I assume you are using the latest beta...could this be the difference?
SP, thanks again for your time and fast responses.
okay, so if it works for you it is not an issue with IB. But as described I get just 0x0 lines with sometimes 1 line showing the complete volume for that bar. I assume you are using the latest beta...could this be the difference?
SP, thanks again for your time and fast responses.
- Attachments
-
- picture1.png
- (19.57 KiB) Downloaded 3505 times
-
- Posts: 37
- Joined: 05 Nov 2005
That MD code is great for TS. It seems to do the trick. I do like the totals of net delta at the bottom of the price bars. Note the clear divergence at the lows in the accompanying chart. Sorry about posting this using TS, but haven't downloaded the recent beta's. Should be similar i would guess.
- Attachments
-
- TS Mkt Delta Divergence at the low.gif
- (61.32 KiB) Downloaded 3510 times
@blauboot
Yes, i use the latest beta.
I added a line TestVolume = Ask[Index] + Bid[Index]; to plot the total volume of all ...x...
I found out that with IB data the code will miss some ticks each bars.
Yes, i use the latest beta.
I added a line TestVolume = Ask[Index] + Bid[Index]; to plot the total volume of all ...x...
I found out that with IB data the code will miss some ticks each bars.
- Attachments
-
- MARKETDELTATEST.ELD
- (13.04 KiB) Downloaded 723 times
-
- MD4.png
- (65.78 KiB) Downloaded 3480 times
Volume Profile plots volume @ price as a histogram. Delta displays volume @ bid and volume @ ask at each price level. It can be displayed in several ways. It has cuased quite a buzz because it is a good method to guage order flow. Several charting packages have implemented it natively Ensign Software being the most recent. They have done a pretty good job it would seem.I have a question, Nick - what is the principal difference between this and our Volume Profile?
If you plot any of these delta studies in MC they only start ploting from when you apply them. They do not plot historical data. Try one of the studies and you will see. Here is a screenshot of delta plotted over time in a couple of different ways. You will see it dosen't start plotting untill 7.38 when I opened MC.
Cheers,
Nick.
- Attachments
-
- picture11.png
- (31.85 KiB) Downloaded 3485 times
-
- Posts: 58
- Joined: 25 Sep 2005
- Location: UK
I decided to take a look at this indicator but am getting this problem also. Is it caused by the Exchange settings or by the chart window itself?It's the price scale alright, I just solved the problem myself when I noticed "SP"'s post
Unfortunately, I don't have two different charting packages to compare price scales etc. I've tried some changes to get this to work but they haven't worked. can someone let me know so i can make the update and see how this thing works?
Thx
D
@fundjunkie: You need to setup the symbol in QuoteManager AND you have to do it BEFORE opening any charts for that symbol,
if you are using any of the symbol SP gave the config for you can refer to this copy-paste of his original text....:
..............Pricescale.........MinM.......BPV
FDAX.......1/10................5...........25
FGBL........1/100..............1...........1000
ER2..........1/10...............1...........100
ES............1/100..............25..........50
Once again, do this BEFORE opening a chart for that symbol.
If you use these setting (or proper settings for whatever symbol you are using) you need not touch the code...
Alternatively, you can also change the settings, shutdown MC and reload it, that will do the same thing (in case the workspaces load the charts before you can intervene)...
if you are using any of the symbol SP gave the config for you can refer to this copy-paste of his original text....:
..............Pricescale.........MinM.......BPV
FDAX.......1/10................5...........25
FGBL........1/100..............1...........1000
ER2..........1/10...............1...........100
ES............1/100..............25..........50
Once again, do this BEFORE opening a chart for that symbol.
If you use these setting (or proper settings for whatever symbol you are using) you need not touch the code...
Alternatively, you can also change the settings, shutdown MC and reload it, that will do the same thing (in case the workspaces load the charts before you can intervene)...
@damageboy
I found out that the reason for the "missing ticks" is the line:
[code]
if InsideBid < InsideAsk then
begin
[/code]
If i delete this line the code seems to work good.
In the picture the upper chart is without the line and shows no missing ticks, compared to the lower.
I found out that the reason for the "missing ticks" is the line:
[code]
if InsideBid < InsideAsk then
begin
[/code]
If i delete this line the code seems to work good.
In the picture the upper chart is without the line and shows no missing ticks, compared to the lower.
- Attachments
-
- MD6.png
- (131.94 KiB) Downloaded 3454 times
@SP: Oh, I deleted that one too while working on my DB powered version of the indicator... Just didnt' find any good reason for it.
While we're on the subject of the given code,
I'm not sure this does that "we" want it to:
You'll notice, that when a DownTicks/UpTicks "delta" is detected (XXX <> MyXXX) the entire delta volume is added to that side: "... + MyVol - VolTmp", I think it should be something along the lines of (incomplete code):
Unless there's something even more basic that I'm failing to see here...
I think this relies on TS behavior (unless it s a bug there too) that ensures that the function will run two times for each DownTick/UpTicks change, while this may be very different in MC, depending on the data provider... (perhaps with some prividers such data maybe batched up)
It may be true for MC, that both DnTicks and UpTicks may change between subsequent calls, and THEN, this code would not work properly...
I haven't got around to testing this, since I'm bogged down by making my DB version work flawlessly (lots of ADE related crap), but I think this should be tested as well...
What do you think?
While we're on the subject of the given code,
I'm not sure this does that "we" want it to:
Code: Select all
// Use Upticks/Downticks
if DownTicks <> MyDownTicks then
Bid[Index] = Bid[Index] + MyVol - VolTmp
else if UpTicks <> MyUpTicks then
Ask[Index] = Ask[Index] + MyVol - VolTmp
else
Code: Select all
// Use Upticks/Downticks
if DownTicks <> MyDownTicks then
Bid[Index] = Bid[Index] + DownTicks - MyDownTicks
else if UpTicks <> MyUpTicks then
Ask[Index] = Ask[Index] + UpTicks - MyUpTicks
else
I think this relies on TS behavior (unless it s a bug there too) that ensures that the function will run two times for each DownTick/UpTicks change, while this may be very different in MC, depending on the data provider... (perhaps with some prividers such data maybe batched up)
It may be true for MC, that both DnTicks and UpTicks may change between subsequent calls, and THEN, this code would not work properly...
I haven't got around to testing this, since I'm bogged down by making my DB version work flawlessly (lots of ADE related crap), but I think this should be tested as well...
What do you think?
I believe insidebid and insideask where introduced in the release after the 'stable' one.To be more specific: If price changes the line at the previous price turns to 0x0 and the line with the last price is showing the complete volume for that bar, color coded and displayed on the bid or ask-side depending on wich side that last trade was.
So if the bar is finished I have some 0x0 lines, 1 line with the complete volume for that bar (i.e. 115x0) and a delta value showing the volume (i.e. 115).
Cheers,
Nick.
P.S. you can code your way around that by using 3 data series one for bid one for ask and one for last and comparing last to the bid and ask.
This missing ticks thing concerns me a little. For this condition the market must be crossed (or IB report its crossed). I am not seeing this happen in TWS even with tick aggregation. Perhaps a tick outside the market implies a bid/ask change and that is not implicitly sent? I wonder what is going on here? Could there be a problem with how MC is returning insidebid and insideask? For example in the senario I mentioned if a tick occurs below the previous bid that implies a new bid that is not actually sent?
As an aside there is an alternate way of deciding +ve delta or -ve delta and that is by comparing to the mid point between bid and ask.
Cheers
Nick.
As an aside there is an alternate way of deciding +ve delta or -ve delta and that is by comparing to the mid point between bid and ask.
Cheers
Nick.
- Alex Kramer
- Posts: 834
- Joined: 23 Feb 2006