![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
Greetings,
I have the following code to write to a file, taken directly from MSDN, the file writes to the NT 6.5 folder, and it works just fine: string path = Cbi.Core.UserDataDir.ToString() + 17Closes.inp"; FileInfo fi1 = new FileInfo(path); if (!fi1.Exists) { //Create a file to write to. using (StreamWriter sw = fi1.CreateText()) { sw.WriteLine("Hello"); sw.WriteLine("And"); sw.WriteLine("Welcome"); sw.Close(); Print("Wrote a Line"); } } If I add some code just before that, a "loop" designed to take a sequence of Close periods in order to average them, for example: COUNTER = 17; AI_index = 0; AVERAGE = 0; FIRST_ROUND = 0; LOADER: if(FIRST_ROUND == 0) { value = Close[AI_index]; INPUTS.Set(AI_index, value); AVERAGE += INPUTS[AI_index]; } //FIRST_ROUND is 0 AI_index += 1; if(AI_index < COUNTER){goto LOADER;} Print( "0: " + INPUTS[0]); Print( "1: " + INPUTS[1]); ...etc to INPUTS[16] Suddenly everything changes. The previous output file does not get created, and the Output Window does not show the "Print" commands. Obviously there is a problem being caused by the "looping" code, but I have no idea what it is...seperately both sets of code work perfectly, combined not at all...why? Any ideas appreciated. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
You would need to roll up your sleeves and debug your code e.g. per here: http://www.ninjatrader-support.com/v...ead.php?t=3418
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
Thank you. Is there any efficient way to determine if a price of an instrument is an "even base" number, for example prices like: 1.5600, 1.5500, 1.5400, 1.5300...etc? I believe it is related to my problem.
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Could could try playing with the '%' C# operator. This calculates the remainder.
if ((value * 1000) % 100 == 0) { /* do something */ } Please check out the MS docs for how this works.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Dierk, that seems helpful. Is it possible to pass that Modulo info into another value such as a double or a string?
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Yes it is.
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| When does re-compiled strategy take effect | verge | Strategy Development | 1 | 05-16-2008 03:45 AM |
| Strange T&S output | foxthorn | Miscellaneous Support | 1 | 11-29-2007 09:58 AM |
| Compilation not taking effect | astrolobe | Indicator Development | 5 | 10-25-2007 12:54 AM |
| Strange Strategy behavior | scjohn | Strategy Development | 1 | 07-24-2007 11:35 AM |
| Strange error on compile | maxpi | Indicator Development | 4 | 07-24-2007 07:20 AM |