• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Recognizing market position

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

  • tonynt
    started a topic Recognizing market position

    Recognizing market position

    Hello,

    I want to ask please if it is possible in a script to recognize the marketposition of an instrument. Eg if an entry is done on DOM or chart trader the script should detect the marketposition and if its not flat then managing the trade from the script.

    Thank you!
    Tony

  • NinjaTrader_ChelseaB
    replied
    Hello Tony,

    No, for Ninjatrader 7 it is not supported, as stated by multiple members of our support in the links I have provided you in Post #2.

    This is supported for NinjaTrader 8.

    If you want unsupported code for NinjaTrader 7, you will need to work with a professional consultant or wait for a community member to assist you on the forums.

    Not supported by NinjaTrader Support means that the NinjaTrader Support Team cannot provide code, samples, guidance, direction, tips, or documentation on the subject.

    Leave a comment:


  • tonynt
    replied
    Hello,

    thank you for your reply. I´m lost after weeks of work because of this brick. Isn´t there anyone from support who can give me the snippet how to check if AccountPosition (from an entry outside the script) is flat?

    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Tony,

    I don't have a ready answer.

    Possibly storing a multi-dimensional array of order and position updates and looping through these or writing custom logic that depends on order of events.

    Its not something I'm familiar with. Were it my task, it would be something I work out through coding experience and trial and error.

    Leave a comment:


  • tonynt
    replied
    Hello Chelsea,

    I have no idea what this means. Can´t you give me an hint so that I can find out?

    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Tony,

    This is going to require custom unsupported logic that I'm not going to write.

    I'm showing there are multiple positions. Close all of the other positions.
    If you have only one position open, that position should be the position that updates the account.PositionUpdate event.

    Otherwise you will need some way of identifying which position is updating.

    Leave a comment:


  • tonynt
    replied
    Hello Chelsea,

    I have one step to resolve but couldnt get it. Please, how can I get the Position.Flat from this example here above.

    With if (e.Position.MarketPosition==MarketPosition.Flat) doitonce=true; the bool persists false even when the position from the chart trader is flat.

    I can not finish a project working for several weeks only because of this step. I cant find anything in helpguide or forum.

    Thank you!
    Tony
    Last edited by tonynt; 06-12-2019, 02:02 PM. Reason: explanation

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Tony,

    I am seeing there are two positions in the screenshot you have provided.

    There is a position of 1000 short on $EURJPY.
    There is a position of 1 long on $AUDJPY.

    The account.PositionUpdate is going to trigger for all positions for all instruments that are opened on this account.

    Your code will need to track all of the positions and ensure it is triggering for the correct instrument.

    Leave a comment:


  • tonynt
    replied
    Hello Chelsea,

    thank you for your reply. The problem is now that english is not my language and I really dont understand your first question and thats making all even more difficult for me.
    I have in the code as you see to check if there is a position and if this is a position long. If it is a position long then I´m going to exitshorts and enterlongs on instruments I have to add then.
    I had not thought that there will be a problem when checking the marketposition.

    when I do an entry long from charttrader then it should trigger longs for the instruments we will add in the script.
    when I do an entry short from charttrader then it should trigger shorts for the instruments we will add in the script.

    (if the entries would be from the script then it would not be a problem because then I could check in the code if marketposition is long or short and derive from this the entries.But we have to do the entry with DOM or chart-trader to have it visible in the group and therefore check for the account if there is a long position or a short position. thats all)


    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello tonynt,

    I'm not able to assist with unsupported code, but this thread will remain open for any community members that would to assist.
    This is not supported for NinjaTrader 7. This is supported for NinjaTrader 8.

    That said, there are 2 open positions.
    Do you have code written to identify which position you are interested in?
    Are you wanting to place an order anytime there is a long position with any instrument no matter if there is a short position for any other instrument?

    Leave a comment:


  • tonynt
    replied
    Hello Chelsea,

    thank you for your reply. I have to use NT7 because a fellow needs it in NT7. I attach a screenshot where you can see:

    * in upper left corner the entry with chart trader on sim101
    * in lower left corner another instrument with the script that should do an entry long from the script if there is a long trade
    * upper right you see the short from the instrument with short entry from chart trader and the long entry from script (that should not be)
    * below the code you see the printing statements.

    Thank you for your support!
    Tony
    Attached Files

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello tonynt,

    Are you 100% certain that other traders are getting assistance with items that our support has stated are not supported by the NinjaScript Support team?

    Because this code is not supported, there is no guarantee it will work.

    May I confirm that there is only one position open on the account?

    If you print the e.Position.MarketPosition to the output window are you seeing the positions appear as the positions change?

    If you were using NinjaTrader 8, there are documented methods of accessing the account position that I am able to assist with and provide examples for.

    Leave a comment:


  • tonynt
    replied
    Hello Chelsea,

    I see a lot of replies from support in the forum with helping traders by more than a word!

    Can´t you give me the one line please?

    With if (e.Position.MarketPosition==MarketPosition.Long) EnterLong(1);

    it also triggers the EnterLong(1) when the position on the account is short. Whats wrong here please?

    Thank you!
    Tony

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello tonynt,

    You would need to type the code into the method?

    In the example the argument of the method is e.

    e.Position.MarketPosition

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.

    Leave a comment:


  • tonynt
    replied
    Hello,

    thank you for your reply. OK, but how can this be added in the script here?

    private void OnPosition(object sender, PositionUpdateEventArgs e)
    {
    if(Position.MarketPosition==MarktetPosition.Long) EnterLong(1);
    // Print("OnPosition: " + e.Position.ToString());
    }

    Thank you!
    Tony

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by cirzonorkecv, Yesterday, 11:52 PM
0 responses
6 views
0 likes
Last Post cirzonorkecv  
Started by rickyblah12, Yesterday, 01:01 PM
1 response
12 views
0 likes
Last Post Erwin Beckers  
Started by dadarara, Yesterday, 12:18 PM
0 responses
8 views
0 likes
Last Post dadarara  
Started by joemiller, Yesterday, 07:33 AM
2 responses
13 views
0 likes
Last Post joemiller  
Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
7 responses
38 views
0 likes
Last Post DaveS
by DaveS
 
Working...
X