Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Help with position handling
Collapse
X
-
Originally posted by koganam View PostYou show both orders being filtered by the same BarsInProgress. It is hard to see how that is any different from having no bars filter.
I've been working on this all morning, and anyhow this thing looks impossible to do in the managed approach keeping CalculateOnBarClose = true;
I see 2 solutions:
1. moving to the advance order handling (IOrder), but unfortunately my skills are still poor, and I don't find a proper tutorial that explain how this works;
2. As you've mentioned in your past thread, use CalculateOnBarClose = false; but reading your threads bring me to 2 questions on the code below:
Code:private bool _boolReverseOnOppositeSignal = false; CalculateOnBarClose = true. private void GoShort(string strEntryName) { if (this._boolReverseOnOppositeSignal) ExitLong(); EnterShortLimit(DefaultQuantity, Close[0], strEntryName); }
2. what exactly do I need boolean flag for? wouldn't i get the same by using the code without, like below:
Code:
Code:CalculateOnBarClose = false; private void GoShort(string strEntryName) { ExitLong(); EnterShortLimit(DefaultQuantity, Close[0], strEntryName); }
Comment
-
Originally posted by koganamYou are reading more into my query than there is. The boolean flag that I was using in that code had a completely different purpose. My query was on why I could not exit by market and enter by limit on the same bar if COBC was true. With or without the boolean flag, that code was not viable.
IOW, you are assuming that I was attempting to solve the problem when I made the query of NT support. I was not: I wanted to know why the construct was not working. I was looking to isolate the problem when I made the query: not attempting to solve a problem that I had not at that time properly identified.
I simply gave you the thread as a reference so that you can see that the issue has been previously discussed, so that you would not spend time going over what was already known. The code in that thread is not a solution to the problem: it was merely a demonstartion of how the problem arose.
My understanding so far is that you can only exit by market and enter by limit on the same bar if COBC is set to false, the code below should work fine:
Code:protected override void OnBarUpdate() { //Enter long if (CrossAbove()) { ExitShort(); EnterLongLimit(Close[0] - RngFrac * (High[0] - Low[0])); }
Comment
-
Originally posted by sburtt View PostYour right, thats script is totally incorrect.
I've been working on this all morning, and anyhow this thing looks impossible to do in the managed approach keeping CalculateOnBarClose = true;
I see 2 solutions:
1. moving to the advance order handling (IOrder), but unfortunately my skills are still poor, and I don't find a proper tutorial that explain how this works;
2. As you've mentioned in your past thread, use CalculateOnBarClose = false; but reading your threads bring me to 2 questions on the code below:
Code:private bool _boolReverseOnOppositeSignal = false; CalculateOnBarClose = true. private void GoShort(string strEntryName) { if (this._boolReverseOnOppositeSignal) ExitLong(); EnterShortLimit(DefaultQuantity, Close[0], strEntryName); }
2. what exactly do I need boolean flag for? wouldn't i get the same by using the code without, like below:
Code:
Code:CalculateOnBarClose = false; private void GoShort(string strEntryName) { ExitLong(); EnterShortLimit(DefaultQuantity, Close[0], strEntryName); }
That having been said, in reality, in Stop&Reverse code, Mar****rders really are not as bad as they at first blush might look: in the aggregate, what you lose on one side, you gain on the other, and vice-versa. Then again, I do understand that you may prefer the solution that you are now exploring, separating the exit from the reversal entry, which is much more precise, and does not depend on statistically nulling out slippage.
2. You are reading more into my query than there is. The boolean flag that I was using in that code had a completely different purpose. My query was on why I could not exit by market and enter by limit on the same bar if COBC was true. With or without the boolean flag, that code was not viable.
IOW, you are assuming that I was attempting to solve the problem when I made the query of NT support. I was not: I wanted to know why the construct was not working. I was looking to isolate the problem when I made the query: not attempting to solve a problem that I had not at that time properly identified.
I simply gave you the thread as a reference so that you can see that the issue has been previously discussed, so that you would not spend time going over what was already known. The code in that thread is not a solution to the problem: it was merely a demonstration of how the problem arose.
Comment
-
Originally posted by sburtt View PostI got your point.
My understanding so far is that you can only exit by market and enter by limit on the same bar if COBC is set to false, the code below should work fine:
Code:protected override void OnBarUpdate() { //Enter long if (CrossAbove()) { ExitShort(); EnterLongLimit(Close[0] - RngFrac * (High[0] - Low[0])); }
Comment
-
Originally posted by koganam View PostPlease read my amended response, and take care of the possibilities/dangers that I outlined, regarding whipsaws and invalid entries by close-of-bar.
De facto the indicator I use in my strategy takes as a reference the median point of each bar, rather than the close, this helps reduce noise and very rarely gives false signals, meaning i will try to go live with COBC = false and see how much this differs from my expectations.
again thanks
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ZeroKuhl, Today, 04:31 PM
|
0 responses
7 views
0 likes
|
Last Post
by ZeroKuhl
Today, 04:31 PM
|
||
Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
|
54 responses
5,336 views
0 likes
|
Last Post
by Gaterz
Today, 04:29 PM
|
||
Started by ETFVoyageur, 05-07-2024, 07:05 PM
|
11 responses
74 views
0 likes
|
Last Post
by -=Edge=-
Today, 04:27 PM
|
||
Started by _Zero_, 04-10-2020, 03:21 PM
|
145 responses
7,900 views
6 likes
|
Last Post
by johng2
Today, 04:19 PM
|
||
Started by TheTradingMantis, 01-19-2023, 02:05 AM
|
43 responses
921 views
0 likes
|
Last Post
by jmagaia
Today, 04:13 PM
|
Comment