mapping study
Posted: Dec 26 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.
Here's the code
But my initial idea was to assign each symbol automatically.
I did try with this but I was still using an input.
Which did not work as expected.
How to assign my symbols automatically, without having to use an input?
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.
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");
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;
How to assign my symbols automatically, without having to use an input?