mapping study

Questions about MultiCharts and user contributed studies.
User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

mapping study

Postby arnie » 26 Dec 2016

I'm creating my own mapping study so I can see the exchange symbol instead of the broker's.

I broke the symbol in half, separating the root and the month/year.
I then compare the root to my input so I can have the exchange symbol assigned and plotting that instead, adding also the month/year of the contract.
mapping02.png
(14.09 KiB) Downloaded 450 times
Here's the code

Code: Select all

Input:
Root (""), //symbol without the month
ContractLength (3); // in the case of AMP, it uses 3 digits for the contract month and year (ex. H17)


Variables:
exchSymbol (""),
monthLen (""),
symbolLen (0),
mySymbol (root),
myRoot (""),
ctrMonth ("");

If month(expirationdate) = 3 then begin
ctrMonth = "(Mar)";
end
else
If month(expirationdate) = 6 then begin
ctrMonth = "(Jun)";
end
else
If month(expirationdate) = 9 then begin
ctrMonth = "(Sep)";
end
else
If month(expirationdate) = 12 then begin
ctrMonth = "(Dec)";
end;

monthLen = RightStr(symbol, ContractLength); // contract month and year
symbolLen = StrLen(symbol) - StrLen(monthLen); // symbol without the month
myRoot = LeftStr(symbol, symbolLen); // symbol without the month
mySymbol = exchSymbol + monthLen + ctrMonth; // add the new symbol and the month

//Assigning each symbol
if Root = "TYA" then begin
exchSymbol = "ZN";
end
else
if Root = "FVA" then begin
exchSymbol = "ZF";
end
else
if Root = "USA" then begin
exchSymbol = "ZB";
end
else
if Root = "EP" then begin
exchSymbol = "ES";
end
else
if Root = "ENQ" then begin
exchSymbol = "NQ";
end
else
if Root = "YM" then begin
exchSymbol = "YM";
end
else
if Root = "DL" then begin
exchSymbol = "FGBM";
end
else
if Root = "DB" then begin
exchSymbol = "FGBL";
end
else
if Root = "DSX" then begin
exchSymbol = "FESX";
end
else
if Root = "DD" then begin
exchSymbol = "FDAX";
end;

plot1(myRoot, "Root");
plot2(Root,"mySymbol");
plot3(mySymbol,"Map");
But my initial idea was to assign each symbol automatically.
I did try with this but I was still using an input.

Code: Select all

//Assigning each symbol
if Root = myRoot then begin
exchSymbol = "ZN";
end
else
if Root = myRoot then begin
exchSymbol = "ZF";
end
else
if Root = myRoot then begin
exchSymbol = "ZB";
end
else
if Root = myRoot then begin
exchSymbol = "ES";
end
else
if Root = myRoot then begin
exchSymbol = "NQ";
end
else
if Root = myRoot then begin
exchSymbol = "YM";
end
else
if Root = myRoot then begin
exchSymbol = "FGBM";
end
else
if Root = myRoot then begin
exchSymbol = "FGBL";
end
else
if Root = myRoot then begin
exchSymbol = "FESX";
end
else
if Root = myRoot then begin
exchSymbol = "FDAX";
end;
Which did not work as expected.
mapping.png
(34.02 KiB) Downloaded 450 times
How to assign my symbols automatically, without having to use an input?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: mapping study

Postby Henry MultiСharts » 06 Jan 2017

Hello arnie,

There is no access to symbol's root in PowerLanguage. Such functionality is available in MultiCharts .NET only.
Your solution of parsing the instrument's name is the correct one.


Return to “MultiCharts”