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
Problem with trade signal
Collapse
X
-
Problem with trade signal
In my strategy, i have "calculate on intrabar" (not at end). I think what happens with that is with each tick inside that bar, a new signal is generated, so with each tick a new position is being ordered. i do have maximum of 5 contracts per direction set. So in a way, 5 trades are occuring within that one bar. Is there anyway I can set it, so the signal is generated on intrabar basis but order is filled only once within that bar (not necessarily at the end oif the bar), so that the second trade will occur only on a new signal generated by another bar. Thanks.Tags: None
-
Help in the attached file
Josh, Thank you. I am really not sure how to proceed with this. I have attached the strategy here, can you please tell me exactly where and what should be added. I had to delete somed of the text from the file because the attachmentr thing kept saying file too big, i hope i have not deleted any important parts. Thanks.Attached Files
Comment
-
Code:[COLOR=blue][FONT="]if[/FONT][/COLOR][COLOR=black][FONT="] (CrossAbove(Stochastics([/FONT][/COLOR][COLOR=purple][FONT="]7[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]14[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="]).K, Stochastics([/FONT][/COLOR][COLOR=purple][FONT="]7[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]14[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="]).D, [/FONT][/COLOR][COLOR=purple][FONT="]1[/FONT][/COLOR][COLOR=black][FONT="])[/FONT][/COLOR] [COLOR=black][FONT="] && MAX(Stochastics([/FONT][/COLOR][COLOR=purple][FONT="]7[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]14[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="]).K, [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="])[[/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="]] < [/FONT][/COLOR][COLOR=purple][FONT="]20[/FONT][/COLOR] [COLOR=black][FONT="] && MAX(VOL(), [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="])[[/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="]] >= [/FONT][/COLOR][COLOR=purple][FONT="]120000[/FONT][/COLOR][COLOR=black][FONT="])[/FONT][/COLOR] [COLOR=black][FONT="]{[/FONT][/COLOR] [COLOR=black][FONT="] DrawArrowUp([/FONT][/COLOR][COLOR=maroon][FONT="]"My up arrow"[/FONT][/COLOR][COLOR=black][FONT="] + CurrentBar, [/FONT][/COLOR][COLOR=blue][FONT="]true[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="], Low[[/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="]] + -[/FONT][/COLOR][COLOR=purple][FONT="]8[/FONT][/COLOR][COLOR=black][FONT="] * TickSize, Color.Turquoise);[/FONT][/COLOR] [COLOR=black][FONT="] EnterLong(DefaultQuantity, [/FONT][/COLOR][COLOR=maroon][FONT="]""[/FONT][/COLOR][COLOR=black][FONT="]);[/FONT][/COLOR] [COLOR=black][FONT="]}[/FONT][/COLOR]
Code:[COLOR=blue][FONT="]if[/FONT][/COLOR][COLOR=black][FONT="] (CrossAbove(Stochastics([/FONT][/COLOR][COLOR=purple][FONT="]7[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]14[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="]).K, Stochastics([/FONT][/COLOR][COLOR=purple][FONT="]7[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]14[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="]).D, [/FONT][/COLOR][COLOR=purple][FONT="]1[/FONT][/COLOR][COLOR=black][FONT="])[/FONT][/COLOR] [COLOR=black][FONT="] && MAX(Stochastics([/FONT][/COLOR][COLOR=purple][FONT="]7[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]14[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="]).K, [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="])[[/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="]] < [/FONT][/COLOR][COLOR=purple][FONT="]20[/FONT][/COLOR] [COLOR=black][FONT="] && MAX(VOL(), [/FONT][/COLOR][COLOR=purple][FONT="]3[/FONT][/COLOR][COLOR=black][FONT="])[[/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="]] >= [/FONT][/COLOR][COLOR=purple][FONT="]120000 [/FONT][/COLOR][SIZE=4][COLOR=Red][FONT="]&& BarsSinceEntry() > 0[/FONT][/COLOR][/SIZE][COLOR=black][FONT="])[/FONT][/COLOR] [COLOR=black][FONT="]{[/FONT][/COLOR] [COLOR=black][FONT="] DrawArrowUp([/FONT][/COLOR][COLOR=maroon][FONT="]"My up arrow"[/FONT][/COLOR][COLOR=black][FONT="] + CurrentBar, [/FONT][/COLOR][COLOR=blue][FONT="]true[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="], Low[[/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="]] + -[/FONT][/COLOR][COLOR=purple][FONT="]8[/FONT][/COLOR][COLOR=black][FONT="] * TickSize, Color.Turquoise);[/FONT][/COLOR] [COLOR=black][FONT="] EnterLong(DefaultQuantity, [/FONT][/COLOR][COLOR=maroon][FONT="]""[/FONT][/COLOR][COLOR=black][FONT="]);[/FONT][/COLOR] [COLOR=black][FONT="]}[/FONT][/COLOR]
Josh P.NinjaTrader Customer Service
Comment
-
Josh, Thank you very much. Question on logistics: I go to tools- edit ninjascript- strategy - select the strategy to edit - then in the editor I click on view code. The code page appears. Is this where the changes are made because i tried and i cannot typeover the existing text. Is there something else i am supposed to do before i can type over?
Comment
-
If your strategy is still in the Strategy Wizard you cannot edit your code. You will need to press the "Unlock Code" button before you can edit your code. If you press the Unlock Code button you will not be able to use the Strategy Wizard's Condition Builder any more. Please make sure you are done with everything you want to do from the Wizard before doing proceeding.
Alternatively, you can just add the condition via the condition builder. You will find the "Bars since entry" available in the "Misc" section. Just select that from the left side and select > in the middle and "Misc: -> "Numeric value" -> 0 on the right side.Josh P.NinjaTrader Customer Service
Comment
-
Did not work
It did not seem to work. I applied it like you said. This removed all the signals from the chart. I have not watched it long enough to see what happens in real time, but at least the signals that were present before making this change are not there. According tothe other conditions in this set, there should be buys and sells at least one trade for each of the signals.
Comment
-
On my computer for some reason I cannot get a screen shot, it just come out black/gray. I will write out exactly what i have on my "Conditions and Actions" screen:
SET 1
When the following conditions are true:
CrossAbove{Stochastics(7,14,3})K, Stochastics(7.14.3),D, 1}
MAX{VOL()>120000
MAX{Stochastics(7,14,3),K,3)(0) <20
BarsSinceEntry() > 0
Do the following:
DrawArrowUp{"My Up Arrow" + CurrentBar, True, 0, low(0) + -8 * TickSize, Color.Turquoise
EnterLong(DefaultQuantity,"")
Comment
-
Ok. Here is the deal. On the very first trade BarsSinceEntry() will not be greater than 0 and if the very first trade is never entered BarsSinceEntry() will never be greater than 0.
Essentially you will need two Sets then. In Set 1 you want to remove BarsSinceEntry() from the conditions. Instead you want to add a condition that says Variable0 == 0. In the actions you want to add one that sets Variable0 = 1. You can find Variable0 under the "User defined variables" category.
Now in Set 2, you want to copy what you had in Set 1. This time remove the Variable0 from both the condition and action halves. In the condition add the BarsSinceEntry() > 0.Josh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
49 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,235 views
0 likes
|
Last Post Yesterday, 08:07 PM |
Comment