Chennai + India
Posts: 3 since Jan 2019
Thanks Given: 0
Thanks Received: 1
|
Hi Folks,
Im a Newbie to this forum and also for Ninjascript programming and i need a help from senior folks for a typical scenario, i m encountering.
Basically i do trade in indian stock market on Stock futures where every contracts do have specified in lot sizes and due to which when i place a order i have to place for a particular stock future instrument, i have to place in mutiple of lot sizes.
NT8 at the intrument level i have no provision to enter this info and if at all i wanted to run a stategy on a particular symbol then somehow at the NT code level i have to manipulate this info and take care while placing the order.
from initial findings i came to know somewhere at OnStateChange under State.DataLoaded i have to write a code and get this lotsize info for the intrument i happen to trade
i did create a CSV file for the entire symbols with its lot size e.g will look like something below.
RELIANCE 09-19,500
AXISBANK 09-19,200
YESBANK 09-19,1800
Here the first field is my stock instrument with its expiry, and the second field after the comma is its lot size.
Now on my OnStateChange under State.DataLoaded, I have to vlookup the master instrument name and get the lot size and i contructed my Ninja code as indicated below,
However im struckup to figure it out on getting the Try code block and appreciate if could i get a help from you.
----Here is the code i came up so far----------------------------------------
else if (State == State.DataLoaded)
{
path = NinjaTrader.Core.Globals.UserDataDir + "NFO_SEP19.txt"; //file path indicates Text file where the lotsizes of my Stock Future Instrument are saved
MyInstrument= Instrument.FullName // Which Instrument full name (including contract month) of the configured instrument
// Checks to see if the file exists
if (!File.Exists(path))
{
// If file does not exist, let the user know
Print("File does not exist.");
return;
}
// Code to Vookup Master Instrument Name and return the Lot Size.
try
{
}
catch (Exception e)
{
// Outputs the error to the log
Log("Could not get the info you have requested", NinjaTrader.Cbi.LogLevel.Error);
Print(e.ToString());
}
}
Cheers!!
Venkatesh V
|