Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Indicator.Swing to Strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Indicator.Swing to Strategy

    Hello I tried to convert the Swing Indicator to a Strategy Called SwingSpin. What is the easiest way to do that? I created a strategy template in Strategy Builder called SwingSpin, debugged down to 1 error. See highlighted error message code chunk below. Looks like the compiler doesnt recognize an Array List used to store cache values of of swing.highs and swing.lows. What's going on here? Would it work to store the lastHighCache & lastLowCache values as a Series<double> lastHighCache & Series<double> lastHighCache?

    Error; The type or namespace name 'ArrayList' could not be found (are you missing a using directive or an assembly reference? CS0246)

    public class SwingSpin : Strategy
    {
    private int constant;
    private double currentSwingHigh;
    private double currentSwingLow;
    private ArrayList lastHighCache;
    private double lastSwingHighValue;
    private ArrayList lastLowCache;
    private double lastSwingLowValue;
    private int saveCurrentBar;
    private Series<double> swingHighSeries;
    private Series<double> swingHighSwings;
    private Series<double> swingLowSeries;
    private Series<double> swingLowSwings;


    Thanks in advance!

    #2
    Hello Kicks.Spin,

    Thanks for your question.

    It may be best to build a strategy using the NinjaScript methods provided by the swing indicator.

    https://ninjatrader.com/support/help...nt8/?swing.htm

    However, to answer your compilation questions, please see below.

    You can open the Swing indicator and use Intelliprompt by placing your mouse over ArrayList to see the fully qualified namespace, and you can use the fully qualified namespace in your script.

    Intelliprompt - https://ninjatrader.com/support/help...elliprompt.htm

    You could also add a using directive at the top of your script so you can use ArrayList without the fully qualified namespace. You may see the using directives at the top of the Swing indicator to see what it uses.

    Click image for larger version  Name:	NinjaTrader_2021-03-12_12-29-20.png Views:	0 Size:	3.2 KB ID:	1146368

    You may also see Microsoft documentation on ArrayList to see how it would be used and the using directives needed. (Publicly available link)

    https://docs.microsoft.com/en-us/dot...t?view=net-4.8

    Please let us know if you have any additional questions.
    Last edited by NinjaTrader_Jim; 03-12-2021, 01:36 PM.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by PaulMohn, Today, 03:49 AM
    0 responses
    3 views
    0 likes
    Last Post PaulMohn  
    Started by inanazsocial, Today, 01:15 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by rocketman7, Today, 02:12 AM
    0 responses
    10 views
    0 likes
    Last Post rocketman7  
    Started by dustydbayer, Today, 01:59 AM
    0 responses
    2 views
    0 likes
    Last Post dustydbayer  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    23 views
    0 likes
    Last Post trilliantrader  
    Working...
    X