Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
limit order entries on a bar
Collapse
X
-
I wish to extend my thanks to Ninjatrader_Jim (Great Video), ChelseB and Conar for the Patience and help you have given me as the solution to this problem has been resolved.
Great support thank you.
-
HI Conan108
Many, Many thanks for that !
re-typed the code if(IsFirstTickOfBar)
{
DoOnce = true;
}
and didn't require the ";" and compiled fine. likely I disturbed something before.
script seems to working ok, giving it some testing!
Thanks
Leave a comment:
-
Many thanks for pointing that out, I will generate the code again from the Strategy Builder, and try a new script.
Thanks again for your offer to look at the code, Ill make sure I haven't any fat fingers when I try above and get back
Thanks again, appreciated.
Leave a comment:
-
This code:
Code:if(IsFirstTickOfBar); { DoOnce = true; }
If the C# syntax checker required the ';' after if(IsFirstTickOfBar) then there is probably a syntax error somewhere else that you're not aware of. If you're willing to post more of your code surrounding this area, I might see the other syntax error.Last edited by Conan108; 10-03-2017, 12:42 AM.
Leave a comment:
-
HI Jim
I have unlocked the code and have the following
Alert(@"TrendsMK3_2", Priority.Medium, @"Exit Long", @"", 600, Brushes.Transparent, Brushes.Green);
if(IsFirstTickOfBar);
{
DoOnce = true;
}
I have the strategy as in the video.
The strategy is working ok, but is still making multiple trades in one bar ?
The code required the ";" after if(IsFirstTickOfBar)
Everything looks in the right place, is there anything else that should be in pace?
I am using playback for testing
May I send the script to see why this isn't working?
Many thanksLast edited by fredfred123; 10-01-2017, 02:06 PM.
Leave a comment:
-
Hi
I really do not want to unlock the code.
Is there another way round this with the strategy builder ?
such as "after the first trade don't make another till the next bar " ?
or after the first trade delay to next bar?
sorry this is the last piece in the jigsaw,
The Bool condition sets workflow to another Strategy Builder set just need to put something in there to stop any more trades till the next bar opens?
Thanks
Leave a comment:
-
Hello fredfred123,
There is a property called IsFirstTickOfBar that can tell you when a new bar is being built when Calculate is set to Calculate.OnEachTick. This property is not available in the Strategy Builder and will require manual programming.
You may wish to write the strategy using the Strategy Builder, and then unlock the code to add a condition like below to reset the bool within OnBarUpdate().
Code:if(IsFirstTickOfBar) { doOnce = true; }
Here is a link on IsFirstTickOfBar for further reference: https://ninjatrader.com/support/help...ttickofbar.htm
If there is anything else I can do to assist, please let me know.
Leave a comment:
-
Hi Jim
Did I miss this this as the set2 if All ?
Default input(0)>=open(0)
would that syntax be the new bar opening.
then do the following reset bool to True
If I have this right
I have looked through the conditions and could you tell me where it is under ?
I understand setting up the bool variable but am stuck setting the condition that reset the bool to true on a new bar.
the aim is 1 bar = 1 trade only
Many thanksLast edited by fredfred123; 09-29-2017, 11:16 AM.
Leave a comment:
-
Thank you Jim
I have this so far?
If the Entry condition sets (long or short)If all set1 has bool = true
Do the following set bool = false
now no more entries can be made until bool is set to true
It is the reset when on a new bar starts that I can't work out. how is this reset to true on a new bar ?
You mention on bar update, I am calculating on each tick so it would be the first tick of a new bar sets the bool back to True. What syntax would I use ?
As your video shows I have another set, set2 has my entry condition then
Do the following set bool =True
but this part should only be set to true on a new bar?
set 2 "if all' has the "entry condition"
bit I can't grasp "only if a new bar"
Do the following set bool to true
Many thanks
I have looked over old posts for this but I think some commands have changed in NT8?
Leave a comment:
-
Hello fredfred123,
I have created a quick demonstration video showing how you can use a doOnce bool to model the behavior you are looking for.
Demo: https://www.screencast.com/t/ES7rzmaV4lZ
Please let me know if this detail does not resolve your inquiry.
Leave a comment:
-
If I may clarify on my gaol
I have a working strategy but have multiple trades opening in certain conditions. NT8
I want to achieve the following
Using the strategy builder the strategy will try to open up a trade when conditions are right
When the logic of the strategy is right for a trade on a bar, a trade would be initialised.
The problem arises when the bar that has just opened and is set to trade, but price fluctuates and the strategy will make multiple orders long and short as the price moves off the point that triggers the trade.
My goal is only allow one trade when the bar opens when the strategy is ready to trade, I initially said two, but I think this complicates the issue. One will be fine
The issue is focused on the one bar that has just triggered the trade. I have the calculation on each tick as On bar close will not work with this strategy.
The focus is on that Bar that the strategy wants to place a trade on, and only allow the first trigger to trade.
I see I could use an integer or bool to set a condition true or false, one or two for an integer, but not sure how I can make the script see the bar opening place the restriction for that bar of one trade only, and reset for the next bar ?
Can this be done in the bounds of the Strategy Builder ? I don't want to unlock the code as this would stop me adding to it with the Strategy Builder.
Not being a coder, and I could not find anything on the Ninja script videos with detail such as this, I am struggling and any help would be greatly appreciated.
My previous post is my attempts to understand the workflow but is not working?
The reference to a previous thread ( with thanks ) looks like a similar problem on a day basis and not on one bar, again I am not sure how I can relate it the Ninja script in the Strategy Builder. I tried to have a look at the download script for clues and it is an older version for NT8
Many thanksLast edited by fredfred123; 09-29-2017, 03:49 AM.
Leave a comment:
-
Thank you for your reply
would this set up the Integar ? I have called it Integar
if all
Integar<2
-------------------------------
Do the following
Integar = 1;
--------------------------------
I think to reset would be ( not sure where to put it? )
If All
Position.MarketPosition=MarketPositionFlat
Integar>2
----------------------------------------------------
Do This
Integar=0
but would I make another set for it?
Many thanks
Leave a comment:
-
Hello fredfred123,
You can limit the number of orders per bar or per day in the logic of your script.
I would recommend you use integer as counter. On each order increment the counter. Require the counter be less than 2 to place a new order. Reset the counter to 0 on the first tick of a new bar.
An example of limiting orders to one trade per day can be found on the forum post linked below.
https://ninjatrader.com/support/foru...ad.php?t=71164
Leave a comment:
-
limit order entries on a bar
I wonder if this is possible?
With my strategy if the price sits and just deviates on a per pip basis on a bar and that is the threshold of my order entry, every time the price moves an order is created.
So before price moves one way or another multiple orders are created.
Is there a way to limit orders on a bar to a maximum of say 2 ?
using on bar close is not an option for me
Appreciate any help
ThanksLast edited by fredfred123; 09-28-2017, 02:01 PM.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Emma1, Yesterday, 07:15 PM
|
1 response
7 views
0 likes
|
Last Post
![]()
by MicroTrends
Today, 01:31 AM
|
||
Started by elliot5, Today, 12:45 AM
|
3 responses
8 views
0 likes
|
Last Post
![]()
by elliot5
Today, 01:47 AM
|
||
Started by sgordet, Yesterday, 08:50 PM
|
1 response
12 views
0 likes
|
Last Post
|
||
Started by futurenow, Yesterday, 07:17 PM
|
0 responses
9 views
0 likes
|
Last Post
![]()
by futurenow
Yesterday, 07:17 PM
|
||
Started by n8dogg59, 05-10-2019, 08:00 AM
|
14 responses
624 views
0 likes
|
Last Post
![]()
by brownsfan019
Yesterday, 06:06 PM
|
Leave a comment: