thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
3 bar up / down trend
Collapse
X
-
Hello benrock,
Thanks for your post and I am happy to assist you.
You can code a 3 bar uptrend/downtrend within the strategy itself. A basic code would look like
You can easily create the basic framework using the Strategy Wizard.Code:if (CurrentBar < 3) return; if (Close[0] > Close[1] && Close[1] > Close[2] && Close[2] > Close[3]) { //do something }
Also please see this YouTube video tutorial on the Strategy Wizard.
You can also consult our NinjaScript consultants to create it for you. You can get the list of our NinjaScript consultants from here http://www.ninjatrader.com/partners#...pt-Consultants
Please let me know if I can assist you any further.JoydeepNinjaTrader Customer Service
-
Hello benrock,
The basic configuration via the strategy will be like as shown in the attached picture.
Please note after you have coded the strategy you have to unlock the strategy and add the below code just below OnBarUpdate.
Please let me know if I can assist you any further.Code:protected override void OnBarUpdate() { if (CurrentBar < 3) return; //rest of the codesJoydeepNinjaTrader Customer Service
Comment
-
Hello benrock,
Since you are referencing to 3 bars back, you have to make sure there are enough bars in the data series you are accessing. Please read this post for further describes it http://ninjatrader.com/support/forum...ead.php?t=3170
Unfortunately you cannot check the bars back via the Strategy Wizard. You have to unlock the Wizard (click the Unlock button in the wizard as shown in the attached picture) and append the below code via the NinjaScript editor manually in order to do so.
Please let me know if I can assist you any further.Code:protected override void OnBarUpdate() { [B]if (CurrentBar < 3) return;[/B][COLOR="Green"] // add this line to your code manually[/COLOR] //rest of the codesJoydeepNinjaTrader Customer Service
Comment
-
ok i made the strategy but when i go to backtest it is not on the list of stratergies , but it is on the list to the left .
whats wrong here ?
\
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description3bartrend]
public class MyCustomStrategy : Strategy
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, 2);
SetStopLoss("", CalculationMode.Ticks, 3, true);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar < 3) return;
//rest of the codes
// Condition set 1
if (Close[0] > Close[1]
&& Close[1] > Close[2]
&& Close[2] > Close[3])
{
}
}
#region Properties
#endregion
}
}
Comment
-
Hello benrock,
Once you have unlocked the code please make sure you have compiled it.- In Control Center menu bar goto Tools>Edit NinjaScript>Strategies
- In the Strategies dialog select MyCustomStrategy and click on the Ok button.
- In the NinjaScript Editor press F5 to compile it.
Also to understand the issue better, can you share a screenshot showing the issue?
To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.
For detailed instructions please visit the following link
I look forward to assisting you further.JoydeepNinjaTrader Customer Service
Comment
-
Hello benrock,
The code I presented only filters the conditions. You need to further code it (via the wizard or the NinjaScript editor) as per your requirement. Please let me know if you have any specific query.
If you are new to creating strategies then please go through this YouTube video which demonstrates how to create strategies via the Strategy Wizard.
Also please go through the educational resources from our help files http://www.ninjatrader.com/support/h...strategies.htmJoydeepNinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
649 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 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
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
576 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment