Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Doji for a strategy question
Collapse
X
-
-
-
Hello,
Thank you for the reply.
I could not suggest anything more specific than what has been provided already, to know why the logic you are asking about is not working correctly you would need to test the code you are using to see why it is not working as expected.
In the previous posts there have been samples provided on how to use conditional if statements in relation to your question. Our support can not write the code for you as only you know what will be correct for your trading goals, instead we can only provide general samples for you to learn from. In this case a general sample was provided in post #42, one sample showing a standard if else else if statement and another showing the syntax you were asking about specifically.
If the syntax is not working as you expected it to, you could utilize the tools you have in the platform to debug why that is not working as expected. Generally you would utilize Print statements and the Tools -> Output window for this process.
Starting with the outside if block, you could check the values being used in that condition and Print them. If the values are as expected for the condition, you could move into the next inner if statement and check it next and so on. This would be a process you would need to complete as you know what values should make the condition equate to true.
If you are having difficulties determining the problem, please post the code you are using and also the Prints you have added. This would allow you to also include the output you had seen to explain the problem in more detail.
I look forward to being of further assistance.
Comment
-
I don`t ask to write the code for me.All i needed was the three conditions to be true before the entry is triggered(All on COBC = false).Is that hard to gather?Jessica`s example is working fine but it covers only two conditions before the entry is triggered.Zachary`s example simply doesn`t work.What else should i ask,add,provide,etc?Three conditions that would be true on COBC = false before the entry is triggered.Please let me know.Originally posted by NinjaTrader_Jesse View PostHello,
Thank you for the reply.
I could not suggest anything more specific than what has been provided already, to know why the logic you are asking about is not working correctly you would need to test the code you are using to see why it is not working as expected.
In the previous posts there have been samples provided on how to use conditional if statements in relation to your question. Our support can not write the code for you as only you know what will be correct for your trading goals, instead we can only provide general samples for you to learn from. In this case a general sample was provided in post #42, one sample showing a standard if else else if statement and another showing the syntax you were asking about specifically.
If the syntax is not working as you expected it to, you could utilize the tools you have in the platform to debug why that is not working as expected. Generally you would utilize Print statements and the Tools -> Output window for this process.
Starting with the outside if block, you could check the values being used in that condition and Print them. If the values are as expected for the condition, you could move into the next inner if statement and check it next and so on. This would be a process you would need to complete as you know what values should make the condition equate to true.
If you are having difficulties determining the problem, please post the code you are using and also the Prints you have added. This would allow you to also include the output you had seen to explain the problem in more detail.
I look forward to being of further assistance.
Comment
-
Hello,
Unfortunately this is not a valid sample as it seems there are missing curly braces and is not valid structure to compile. If you meant to create a sample similar to the one in post # 45 or a nested if statement, I will append the missing braces to your sample and highlight them in Orange. I did note there was a backwards curly brace in the original post #45 and I have corrected it.
This logic would not be possible and I will explain why.
Let us assume the Close of the current bar is Greater than the Open of the current bar: Close[0] > Open[0]
The first portion of your statement is true:
The second condition could not become true, The close cant be lower than the open and also higher than the open in the same bar
Please let me know if I may be of additional assistance.Code:[COLOR="seagreen"]if (Close[0] > Open[0]) { [/COLOR] [COLOR="red"] if (Close[0] < Open[0]) {[/COLOR] if (Close[0] > Open[0]) { } [B][COLOR="DarkOrange"] } }[/COLOR][/B] { }
Comment
-
Thank you for your reply.Originally posted by NinjaTrader_Jesse View PostHello,
Unfortunately this is not a valid sample as it seems there are missing curly braces and is not valid structure to compile. If you meant to create a sample similar to the one in post # 45 or a nested if statement, I will append the missing braces to your sample and highlight them in Orange. I did note there was a backwards curly brace in the original post #45 and I have corrected it.
This logic would not be possible and I will explain why.
Let us assume the Close of the current bar is Greater than the Open of the current bar: Close[0] > Open[0]
The first portion of your statement is true:
The second condition could not become true, The close cant be lower than the open and also higher than the open in the same bar
Please let me know if I may be of additional assistance.Code:[COLOR="seagreen"]if (Close[0] > Open[0]) { [/COLOR] [COLOR="red"] if (Close[0] < Open[0]) {[/COLOR] if (Close[0] > Open[0]) { } [B][COLOR="DarkOrange"] } }[/COLOR][/B] { }
Regarding the brces,that was an example Zachary provided.
I think you are wrong about the second condition.This is the "a doji for a strategy" thread.How it`s not possible for the close to be lower then the open(second condition) on a developing,current bar?Please tell me.
It can alternate back and forth multiple times during a developing bar.Last edited by outsource; 09-17-2016, 08:03 PM.
Comment
-
Hello,
Please test this logic and Print the values if you are not positive that I am correct of the answer.
I would disagree with your statement as the logic would all be executed at once and the if statements are nested. The values being used are all the same.
If you take the variables away it would look like this:
Please let me know if I may be of further assistance.Code:if (2000 > 1998) { if (2000 < 1998) { if (2000 > 1998) { } } }
Comment
-
I`ll try to ask it again,if you don`t mind.
The example provided by Jessica works fine and it`s as follows:
if(! thickMet)
{ if ( (High[0] > High[1]) && (Low[0] < Low[1]) )
{
thickMet = true;
}
}
else
{ if ( (High[0] < High[1]) && (Low[0] > Low[1]) )
{
enter
}
}
}
Replace the above two conditions with the following :
Close[0] > Open[0](first condition)
Close[0] < Open[0](second condition)
And It would also work!
Now the question is,How would i add the third condition so it would work for all the three to be true before the entry is triggered?
Thank you in advance!!!
Comment
-
Your thinking may be a bit muddled in this one. The point is that the conditions that you have written cannot be simultaneously true on any single tick. NT processes on every tick that updates the bar. The only difference is that with COBC false, you can have multiple ticks per bar, but with COBC true, there is always only one tick per bar.Originally posted by outsource View PostThank you for your reply.
Regarding the brces,that was an example Zachary provided.
I think you are wrong about the second condition.This is the "a doji for a strategy" thread.How it`s not possible for the close to be lower then the open(second condition) on a developing,current bar?Please tell me.
It can alternate back and forth multiple times during a developing bar.
You have to look at the statements in a block and evaluate them as a unit. On any one tick, your conditions cannot be met, and that is in an absolute sense.
Comment
-
I needed it on COBC = false.I already said that hundreds of times.Originally posted by koganam View PostNT processes on every tick that updates the bar. The only difference is that with COBC false, you can have multiple ticks per bar, but with COBC true, there is always only one tick per bar.
Comment
-
Hello outsource,
To clarify, you are looking to add a check for a doji, is this correct? This would be when the close is equal to the open, is this correct?
You want to add this check to the conditions that Jessica provided an example of, is this correct?
Try the following:
With this, if the thickMet bool is set to true on a previous run of OnBarUpdate, and the high of the current bar is less than the high of the previous bar and the low is greater than the low of the previous bar and close of the current bar is equal to the open of the current bar, then place a buy market order.Code:Print(string.Format("{0} | thickMet: {1}", Time[0], thickMet )); if(!thickMet) { if ( (High[0] > High[1]) && (Low[0] < Low[1]) ) { thickMet = true; } } else { Print(string.Format("{0} | High[0]: {1} < High[1]: {2} & Low[0]: {3} > Low[1]: {4}", Time[0], High[0], High[1], Low[0], Low[1] )); if ( (High[0] < High[1]) && (Low[0] > Low[1]) ) { Print(string.Format("{0} | Close[0]: {1} == Open[0]: {2}"); [COLOR="Sienna"][B]if (Close[0] == Open[0]) {[/B][/COLOR] EnterLong(); [COLOR="sienna"][B] }[/B][/COLOR] } }
The prints I have added as example of how you can use prints to understand behavior.
Below is a link to a video that demonstrates this as well.
As a tip, I recommend that you place each curly brace on its own line so that you can ensure each call is within the action block of the proper branching command (condition set).
As another small tip, you are requiring that the (High[0] < High[1]) && (Low[0] > Low[1]) be true on two calls in a row. In other words, by requiring the thickMet to be true (which is set to true with the same condition) and by using an else if, this means after thickMet is set to true you have to wait for the next run of OnBarUpdate before the else if will be checked. Thus, that same condition has to be true twice.Last edited by NinjaTrader_ChelseaB; 09-19-2016, 08:57 AM.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment