NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support > Historical Version 7 Beta Threads > Version 7 Beta General Questions & Bug Reports

Version 7 Beta General Questions & Bug Reports Ask questions here and post bug reports.

 
 
Thread Tools Display Modes
Old 12-14-2009, 08:16 AM   #1
ATI user
Senior Member
 
ATI user's Avatar
 
Join Date: Apr 2006
Location: Toronto
Posts: 1,321
Thanks: 1
Thanked 7 times in 7 posts
Default FlattenEverything from code...negates race condition

I am getting uncovered positions trading live cash

this is because I am using AtmStrategyClose which is reversing me due to race condition

I would much prefer to be able to 'FlattenEverything' from my code instead of closing each position separately....this would negate any possibility of a race condition reverse

Is this possible in 7?
ATI user is offline  
Old 12-14-2009, 08:29 AM   #2
ATI user
Senior Member
 
ATI user's Avatar
 
Join Date: Apr 2006
Location: Toronto
Posts: 1,321
Thanks: 1
Thanked 7 times in 7 posts
Default

or possibly this would work in conjunction with AtmStrategy code?


if (Position.MarketPosition == MarketPosition.Long )
{
ExitLong();
Print(" ");
Print(" EXIT UNCOVERED LONG "+ToTime(Time[0]) );
}
else if ( Position.MarketPosition == MarketPosition.Short )
{
ExitShort();
Print(" ");
Print(" EXIT UNCOVERED SHORT "+ToTime(Time[0]) );
}
return;
ATI user is offline  
Old 12-14-2009, 10:31 AM   #3
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

ATI user,

NS entry/exit method/properties would not influence your ATM strategy calls. Meaning, if you entered a position via AtmStrategyCreate, Position.MarketPosition would not pick it up as a long/short as that is not a NinjaScript position.
NinjaTrader_Josh is offline  
Old 12-14-2009, 10:55 AM   #4
Mindset
Senior Member
 
Join Date: Mar 2008
Location: UK West Sussex
Posts: 667
Thanks: 10
Thanked 11 times in 8 posts
Default Poss solution?

Ati user

I don't use strategies but would an oif work?

CLOSEPOSITION COMMAND
CLOSEPOSITION;<ACCOUNT>;<INSTRUMENT>;;;;;;;;;;

I believe this is the equivalent of hitting the close button in ChartTrader and has never resulted in the conditions you have experienced.

( search order instruction files after F1 help)
Mindset is offline  
Old 12-14-2009, 03:54 PM   #5
ATI user
Senior Member
 
ATI user's Avatar
 
Join Date: Apr 2006
Location: Toronto
Posts: 1,321
Thanks: 1
Thanked 7 times in 7 posts
Default

Josh
Thanks. I had a suspicion they might be handled differently

Mindset
Thanks. OIFs are new to me and seem like the solution. I would want to use

FLATTENEVERYTHING;;;;;;;;;;;;

now I need to read up on how to implement them.

You say you do not use strategies....does this mean you use your own custom command code instead? i.e. OIFs
ATI user is offline  
Old 12-15-2009, 12:01 AM   #6
Mindset
Senior Member
 
Join Date: Mar 2008
Location: UK West Sussex
Posts: 667
Thanks: 10
Thanked 11 times in 8 posts
Default command code

Ati user

Yes - I am a discretionary rule based trader and I tried for years to get a coded strategy to fit me but did not succeed.
oif's are ok but be aware they don't do simulated orders so if you want say a neg stop limit order - you can't do it.
They are also a real pain to write correctly so use the oif builder(tools-options-ati).
Mindset is offline  
Old 12-15-2009, 01:12 AM   #7
Mindset
Senior Member
 
Join Date: Mar 2008
Location: UK West Sussex
Posts: 667
Thanks: 10
Thanked 11 times in 8 posts
Default position recognition

Josh

Could you outline why NT doesn't see an oif order fill as a position - is there any way to use position commands on oif orders in v7 perhaps?
Mindset is offline  
Old 12-15-2009, 06:59 AM   #8
ATI user
Senior Member
 
ATI user's Avatar
 
Join Date: Apr 2006
Location: Toronto
Posts: 1,321
Thanks: 1
Thanked 7 times in 7 posts
Default

in another thread
Last edited by ATI user; 12-15-2009 at 08:36 AM.
ATI user is offline  
Old 12-15-2009, 11:05 AM   #9
ATI user
Senior Member
 
ATI user's Avatar
 
Join Date: Apr 2006
Location: Toronto
Posts: 1,321
Thanks: 1
Thanked 7 times in 7 posts
Default

I am writing an oif.txt file to NinjaTrader 7/incoming folder

the file shows up(see attached) but is not executed...in sim101 ...live feed....i.e. positions and stops are left open

text is from OIF Builder...where Write File was checked

ATI is enable from File menu


WriteFile("oif3.txt", "FLATTENEVERYTHING;;;;;;;;;;;;");
Attached Images
File Type: png oif3.png (24.4 KB, 14 views)
ATI user is offline  
Old 12-15-2009, 11:06 AM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Mindset,

OIFs are similar to manual trades. In 6.5 and 7, manually placed trades are not "seen" or managed by a NinjaScript Strategy.
NinjaTrader_Josh is offline  
Old 12-15-2009, 11:07 AM   #11
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

ATI user,

Any Control Center log messages?
NinjaTrader_Josh is offline  
Old 12-15-2009, 11:10 AM   #12
ATI user
Senior Member
 
ATI user's Avatar
 
Join Date: Apr 2006
Location: Toronto
Posts: 1,321
Thanks: 1
Thanked 7 times in 7 posts
Default

none....had them when path was wrong....none since path is right and file is written in correct folder
Last edited by ATI user; 12-15-2009 at 11:29 AM.
ATI user is offline  
Old 12-15-2009, 12:03 PM   #13
ATI user
Senior Member
 
ATI user's Avatar
 
Join Date: Apr 2006
Location: Toronto
Posts: 1,321
Thanks: 1
Thanked 7 times in 7 posts
Default

found bug....I assume

1. would not work so I thought maybe I needed to start NT with ATI enabled...did that....worked perfectly....ATI processing then executed in Log

2. then enabled strat....it restarted, wrote the iof file to incoming...however it was not executed

3. thought maybe I needed to remove the strat after a flatten, so I did....enabled new strat....wrote iof to folder however did not execute.

so...unless you are only allowed to do this once, must be a bug related to not resetting something after flatten

4. question: flatten happens so fast I could not see the iof file written and deleted. Please confirm iofs are deleted from incoming folder after execution
Last edited by ATI user; 12-15-2009 at 12:25 PM.
ATI user is offline  
Old 12-15-2009, 12:13 PM   #14
ATI user
Senior Member
 
ATI user's Avatar
 
Join Date: Apr 2006
Location: Toronto
Posts: 1,321
Thanks: 1
Thanked 7 times in 7 posts
Default

5. same results exactly as above when running in Market Replay....i.e. works perfectly once after restart and then not again

the help notes say you can test in 'live feed....' inferring it maybe would not work in MR...glad it does

NOTE: switching feeds does not reset the function...you must restart NT
Last edited by ATI user; 12-15-2009 at 12:20 PM.
ATI user is offline  
Old 12-15-2009, 01:27 PM   #15
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

ATI user,

I am not experiencing the same thing.

1. Connect data feed
2. Run SampleMACrossOver
3. As it enters a trade, Tools>Options>ATI>OIF builder
4. Submit FlattenEverything OIF
5. Trade closes, strategy shut down as expected.
6. Reenable strategy, strategy trades
7. Submit FlattenEverything OIF
8. Positions all exited again, strategy shut down.

On OIF processing the OIF is deleted from the incoming folder. Please confirm this behavior on your end. If your OIF is removed from the folder it means it was processed. Please see the Control Center logs for messages related to the OIF processing. If it was not processed the OIF file would still be in your directory.
NinjaTrader_Josh is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
race condition atm strats ATI user Version 7 Beta General Questions & Bug Reports 12 01-21-2010 02:17 PM
Race Condition Issue and Order Reject dax3k Automated Trading 7 04-06-2009 08:19 AM
race condition between exitorder and SetTrailStop junkone Automated Trading 3 03-27-2009 02:20 PM
Race Conditions TAJTrades Strategy Development 11 12-15-2008 07:19 AM
multi-time frame code and entry code Mark_486 General Programming 1 05-15-2008 11:54 AM


All times are GMT -6. The time now is 07:01 AM.