I've made some adjustments and it seems to work now even if not well as it should, infact there are a couple of things that don't work fine and I don't know where the problem could be.
Attached you can find some pictures from different instruments with different price scale settings.
All the settings are correct in the Quotemanager for the minmovment, price scale and so on.
So the problem should be in the code.
I've attached also the TXT files from the statement generated from the code for each instrument. The variables, iPrice and Volume are all correct but the string plotting is not so correct.
The first problem is this:
What I notice is that the code works fine and displays for each level of price the correct volume if applied on instruments with price-scale "AS IS" or with no decimals in each minimum movment (FESX , YM). If you apply the code to instruments with price-scale in decimals (ES, NQ, 6E, FDAX, FGBL .....), it displays only the volume for the integer price and not for the decimals.
For example on the €/USD future (6E), it displays only one string even if I've plotted it on 1 tick chart where the average price is equal to close for each tick and iPrice is equal to average price.
The second problem is how to maintain the vertical alignment for the all strings at each new quote. After some seconds, the vertical alignment is lost and you find strings in the middle of the chart. Only the strings referencing the last quotes stay in the right margin of the chart.
Here is the code that I've made for the Volume@Price_string. Any help or suggestion will be very appreciated.
Code: Select all
//CrazyNasdaq date 20101012
//Volume@Price string
//version beta 0.1
Inputs: Txt.Color(red),
Txt.Size(8),
Txt.Bold(false),
Txt.Font("verdana");
Vars: StartPrice(0),
iPrice(0),
MyVolume(0);
Array: Vol.Array[15000](0),
Vol.Txt[15000](0),
Vol.Str[15000](" --- ");
If date = lastcalcdate then begin //this statement make the code begin only if the day is the last day on the chart
MyVolume = Volume;
// Reset Each day at the first TICK
if date > date[1] then begin
iPrice = AvgPrice;
StartPrice = AvgPrice;
for value1 = 0 to 15000 begin //this statement reset all the array to zero
Vol.Array[value1] = 0;
END;
Vol.Array[iPrice] = MyVolume; //this statement assigns the Volume to the first tick of the array
END;
// Calculate the value for the rest of the day past the first TICK
If date = date[1]and StartPrice > 0 then begin
iPrice = avgprice; //is suggested to use 1 tick chart
Vol.Array[iPrice]= Vol.Array[iPrice] + MyVolume; //this collects volume at each new tick and summs Volume with previous volume
END;
Vol.Str[iPrice] = numtostr(Vol.Array[iPrice],0); //this transform numbers of the Volume @ each Price in strings to display
text_Delete(vol.txt[iprice]); //this is to not rewrite the string on the previous string
vol.txt[iPrice]=text_new(d, getAppInfo(aiRightDispDateTime),iPrice,"text string");
text_setstyle(vol.txt[iPrice],1,2);
text_setcolor(vol.txt[iPrice],getbackgroundcolor);
text_setstring(vol.txt[iPrice], vol.str[iPrice]+ " ");
text_setcolor(vol.txt[iPrice],Txt.Color);
Text_SetSize(Vol.txt[iPrice], txt.Size);
text_setattribute(Vol.txt[iPrice], 1 , txt.bold);
text_setfontname(Vol.txt[iPrice], txt.font);
text_setlocation(Vol.txt[iPrice], d, getappinfo(airightdispdatetime), iprice);
{This is the statement that creates the TXT file to control if the code works fine}
Print(File("C:/temp/Volumestring_"+Getsymbolname+".txt")," ",numtostr(date,0), " ", numtostr(time_s,0), " ", numtostr(iprice, 4)," ", numtostr(Vol.Array[iPrice],0));
END;
CrazyNasdaq