Use the following code, which is a good way to access the public DataSeries from the PriceActionSwing indicator within other indicators/strategies.
Like futuretrader mention, it is important, that the assignment of the "SwingRelation" dataseries comes before any other return statement, while the "if (CurrentBar < 1)" part is a leftover from NT 6.5. Or you can use the above code and every thing should work. You can do the same with the data series from the IchiCloud indicator.
The following 4 users say Thank You to dorschden for this post:
Thanks a bunch! My script is working with the changes you mentioned.
I am trying to get my indicator to display in MA (Market Analyzer) now. My signal is basically in 1 of 3 positions.
I have been staring at the template you provided in the thread while I was going through it for YOUR MA, trying to figure out which variables you have exposed and how you did it. But I can't get it to do what I want.
What's weirder, is that as you can see in that column "WT_Up" on my MA template, it has the closing price. Which isn't what I want there.
What is it that I need to make sure my script has so that I can print it to MA? I can change the cell conditions, but where does it look in my script for that information?
I created a new data series called "trendState." Each time I perform my calculations (which have 3 different states), I have been putting a 1,0, -1 into that data series on each bar. I tried to then expose this variable.
Now, it shows up in MA as a selectable option in the 'plot' field. But the output is still just the close of the last bar on my chart, instead of the output of that dataSeries.
Here is what I mean by what I added. And it is in fact printing the proper output to my test window. I just haven't gotten it to work properly with MA.
Last edited by forrestang; July 17th, 2011 at 11:27 AM.
I am trying to use the code to build a strategy but an error on the Log tab comes up showing " Reference to oject .... )
This is the way I am starting to write code. May be you can help me how to use this indicator correctly
#region Using declarations
// This namespace holds all strategies and is required. Do not change it.
/// Enter the description of your strategy here
[Description("Enter the description of your strategy here")]
public class CLSwing : Strategy
// Wizard generated variables
// User defined variables (add any user defined variables below)
/// This method is used to configure the strategy and is called once before any strategy method is called.
protected override void Initialize()
// SetStopLoss("", CalculationMode.Ticks, SaftyStopLoss, false);
//SetProfitTarget("", CalculationMode.Ticks, Profit);
//SetTrailStop("", CalculationMode.Ticks, Stop, false);
// SetStopLoss("", CalculationMode.Ticks, Stop, false);
CalculateOnBarClose = true;
/// Called on each bar update event (incoming tick)
protected override void OnBarUpdate()
if (CurrentBar < 1)
if (swingTrend == null)
swingTrend = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingTrend;
if (swingRelation == null)
swingRelation = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingRelation;
int trend = Convert.ToInt32(swingTrend);
// Down trend - do something
// Up trend - do something
// No trend - do something or nothing
// Or alternative
//if (swingRelatioin == 2)
// Double bottom - do something