Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Simple Strategy and Simple Clip can these strategies be convert to indicators
Collapse
X
-
Hello Xtrader30,
Welcome to the NinjaTrader forums!
Yes, this would be possible to do. You can create a new indicator and copy the variable declarations, the variable assignments in OnStateChange() and the logic in OnBarUpdate().
Leave out the EnterLong() and ExitLong(), as these are specific to strategies to place orders, and replace these with what you would like to see instead, such as a drawing object like a dot.
For the crosses to be signals used in another script, these will need to be set to plot values as well.
Below is a link to an example.
https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/104516-adxvma-with-ninja-8-strategy-builder?p=812238#post812238
Below I am providing a link to a forum post with helpful information about getting started with NinjaScript and C#.
https://ninjatrader.com/support/foru...040#post786040
As well as a link to a the NinjaScript Editor 401 training video on copying code from one script to another.
https://youtu.be/H7aDpWoWUQs?t=1753&...We0Nf&index=14Chelsea B.NinjaTrader Customer Service
-
Hi NinjaTrader_ChelseaB,
Thanks for the great information and quick reply, I don't not much of Ninjatrader script, but I will look into the information and I hope I can follow it
Thanks,
Xtrader30
Comment
-
I got this far and I have the code below for the indicator; however when I compile I got the below errors
namespace NinjaTrader.NinjaScript.Indicators
{
public class EdSimpleClip : Indicator
{
private Series<double> Deriv;
private Series<double> Z3;
private Series<double> Clip;
private Series<double> Signal;
private Series<double> ROC_;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "EdSimpleClip";
IsOverlay = true;
IsSuspendedWhileInactive = true;
SigPeriod = 22;
ROCPeriod = 10;
}
else if (State == State.DataLoaded)
{
Deriv = new Series<double>(this);
Z3 = new Series<double>(this);
Clip = new Series<double>(this);
Signal = new Series<double>(this);
ROC_ = new Series<double>(this);
}
}
protected override void OnBarUpdate()
{
//Add your custom indicator logic here.
if (CurrentBar < SigPeriod || CurrentBar < 49)
return;
// Derivative of the price wave
Deriv[0] = Close[0] - Close[2];
//Normalize Degap to half RMS and hard limit at +/- 1
double RMS = 0;
for (int count = 0; count < 50; count++)
RMS += Deriv[count] * Deriv[count];
if (RMS != 0)
Clip[0] = 2 * Deriv[0] / Math.Sqrt(RMS / 50);
Clip[0] = Clip[0] > 1 ? 1 : Clip[0] < -1 ? -1: Clip[0];
//zeros at Nyquist and 2*Nyquist, i.e. Z3 = (1 + Z^-1)*(1 + Z^-2) to integrate derivative
Z3[0] = Clip[0] + Clip[1] + Clip[2] + Clip[3];
//Smooth Z3 for trading signal
Signal[0] = SMA(Z3, SigPeriod)[0];
//Use Rate of Change to identify entry point
ROC_[0] = Signal[0] - Signal[ROCPeriod];
if(CrossAbove(ROC_, 0, 1))
Draw.Dot();
if (CrossBelow(Signal, 0, 1))
Draw.Diamond();
}
}
}1 Photo
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
573 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