Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

FlattenEverything from code...negates race condition

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    #2
    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;

    Comment


      #3
      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.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        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)

        Comment


          #5
          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

          Comment


            #6
            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).

            Comment


              #7
              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?

              Comment


                #8
                in another thread
                Last edited by ATI user; 12-15-2009, 09:36 AM.

                Comment


                  #9
                  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 Files

                  Comment


                    #10
                    Mindset,

                    OIFs are similar to manual trades. In 6.5 and 7, manually placed trades are not "seen" or managed by a NinjaScript Strategy.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      ATI user,

                      Any Control Center log messages?
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        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, 12:29 PM.

                        Comment


                          #13
                          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, 01:25 PM.

                          Comment


                            #14
                            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, 01:20 PM.

                            Comment


                              #15
                              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.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              603 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              349 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              104 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              560 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              560 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X