Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
About sessions
Collapse
X
-
hello,
The script processes all bars for the timeframe you selected which generally covers multiple sessions. to stop outputting after 1 session you would need to make logic which prevents the print after the first time it happens. you could use a bool variable for that type of use case.JesseNinjaTrader Customer Service
-
Hello ラリー,
I don't know of a specific sample of stopping on the first session, that would be something you would have to make if you wanted to do that. If you are unsure about how to use bool variables in C# I would suggest to research C# educational tutorials on external resources. A very simple example of using a bool would be like the following:
private bool myBoolVariable;
protected override OnBarUpdate()
{
if(someCondition)
{
myBoolVariable = true;
}
if(myBoolVariable == true)
{
}
}JesseNinjaTrader Customer Service
Comment
-
Hello ラリー,
In the image it looks like you just copied/pasted the code that I had provided as a sample and modified the condition. For the print to work once you need to still use that condition for the print. If you are having trouble understanding where to put the different code you see I would suggest using external C# tutorials and guides to first learn about C# language. That will help a lot when working with manually coded NinjaScript. You just haven't used the condition body for the print { Print(...) ;}JesseNinjaTrader Customer Service
Comment
-
Hello ラリー
I had made someCondition meaning any condition you wanted. You need to edit the code to be how you want it, I only provided what is known as pseudo code which can otherwise be though of as a placeholder. You fill in the blanks with what you need, that is just the structure in C# that you would use for that type of condition.
The sample is just showing the basics of using a condition to control a bool variable. If the first condition becomes true, set the bool variable to true. If the bool variable is true the second condition can then be true and work.JesseNinjaTrader Customer Service
Comment
-
Hello ラリー,
You would still need add whatever additional logic you wanted to use that variable the first time it was true. After its true once you would have to reset the variable to false and also stop setting the variable to true by preventing the first condition from happening again.
If you are having a hard time understanding how to make conditions or write conditional logic in manually coded NinjaScript I would suggest to use external C# tutorials to learn C# before working with manually coded NinjaScript. NinjaScript is C# language so having a firm understanding of how to program in C# would be necessary to manually code scripts. You can also reach out to a third party developer to have the item you want created for you.
JesseNinjaTrader Customer Service
Comment
-
Hello ラリー,
I would be unable to provide a full sample here as that would just be coding the item for you, our support cannot create custom sample upon request but we can provide general educational information on topics.
I would suggest to research external C# educational websites and tutorials to learn general C# conditional logic before trying to work with manually coded NinjaScript. Our support won't be able to create code upon request for you so it is important that you have a firm understanding of C# language and how that works before trying to work with manually coded NinjaScript.
There are numerous ways to do a task one time in C#, a very common way would be to use bool variables to make logic with states. You can search online for C# examples of using bool conditions or other conditional logic if you are unsure how to do that. Here is one example, I had used google to search for "c# bool conditions example" and here is a public resource that has basic condition examples: https://www.universalclass.com/artic...rogramming.htm
Once you have a good understanding of how if conditions work with C# you can create any number of conditions in your script to accomplish tasks.
Learning about C# conditions and C# variables would be two very important concepts to start with if you plan to manually code in NinjaScript.
JesseNinjaTrader Customer Service
Comment
-
Thank you for your reply.
I referred to the link you provided.
I think I understand that the code in the wave brackets will be executed if the code describing the condition with if meets the condition.
As for the else statement, I understand that it is to be executed if the condition is not met by the if.
I was not sure if someCondition in if(someCondition) was a function or a variable and searched the Ninja Trader documentation but could not find any hits.
Is someCondition a function?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by f.saeidi, Yesterday, 12:14 PM
|
9 responses
23 views
0 likes
|
Last Post
by f.saeidi
Today, 04:39 AM
|
||
Started by Tim-c, Today, 03:54 AM
|
0 responses
3 views
0 likes
|
Last Post
by Tim-c
Today, 03:54 AM
|
||
Started by FrancisMorro, Today, 03:24 AM
|
0 responses
3 views
0 likes
|
Last Post
by FrancisMorro
Today, 03:24 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
10 responses
1,772 views
0 likes
|
Last Post
by Leafcutter
Today, 03:01 AM
|
||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, 04-23-2024, 07:51 PM
|
2 responses
31 views
0 likes
|
Last Post
by Max238
Today, 02:25 AM
|
Comment