Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

thinkscript custom supertrend strategy conversion to ninjascript

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

    thinkscript custom supertrend strategy conversion to ninjascript

    I know nothing about Ninja script and have tried converting it myself only to fail. So was wondering if anyone could convert this into a strategy that could be automated with buttons to arm short and arm long. Buy long conditions on think script are "buysignal" and the short side entry conditions to buy are "buysignal1"

    here's the think script code

    input AtrMult = .7;
    input nATR = 4;
    input AvgType = AverageType.HULL;
    input PaintBars = yes;
    input showsignals = yes;
    #def
    def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
    def UP = HL2 + (AtrMult * ATR);
    def DN = HL2 + (-AtrMult * ATR);
    def ST = if close < ST[1] then UP else DN;
    def Vinculum = ST;
    def plotlong = if ST crosses below close then 1 else 0;
    def plotshort = if ST crosses above close then 1 else 0;

    plots
    plot x = plotlong;
    Alert (plotlong, Sound.Ring);
    x.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_UP);
    AssignPriceColor(if x then Color.WHITE else Color.CYAN);

    plot y = plotshort;
    Alert (Vinculum, Sound.Ring);
    y.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_DOWN);
    AssignPriceColor(if x then Color.CYAN else Color.WHITE);

    x.AssignValueColor(if close < ST then Color.RED else Color.CYAN);
    AssignPriceColor(if PaintBars and close < ST

    then Color.RED

    else if PaintBars and close > ST

    then Color.GREEN
    else Color.CURRENT);

    x.SetHiding(!showsignals);
    y.SetHiding(!showsignals);



    def ATR1 = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
    def UP1 = HL2 + (AtrMult * ATR1);
    def DN1 = HL2 + (-AtrMult * ATR1);
    def ST1 = if close < ST[1] then UP1 else DN1;

    def trendChangeUp = ST1 crosses above ST[1];
    def closeHigherAfterTrendChange = close > open and close[1] > open[1];
    def trendIsUp = ST1 > ST[1];

    plot BuySignal = trendChangeUp and closeHigherAfterTrendChange and trendIsUp;
    BuySignal.SetPaintingStrategy(PaintingStrategy.BOO LEAN_ARROW_UP);
    BuySignal.SetDefaultColor(Color.GREEN);
    BuySignal.SetLineWeight(2);

    ##### down #####



    def ATR2 = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
    def UP2 = HL2 + (AtrMult * ATR2);
    def DN2 = HL2 + (-AtrMult * ATR2);
    def ST2 = if close > ST[1] then dn2 else up2;

    def trendChangedn = ST2 crosses below ST[1];
    def closelowerAfterTrendChange = close < open and close[1] < open[1];
    def trendIsdn = ST2 < ST[1];

    plot BuySignal1 = trendChangedn and closelowerAfterTrendChange and trendIsdn;
    BuySignal1.SetPaintingStrategy(PaintingStrategy.BO OLEAN_ARROW_down);
    BuySignal1.SetDefaultColor(Color.red);
    BuySignal1.SetLineWeight(2);​

    #2
    Originally posted by Dalton8883 View Post
    I know nothing about Ninja script and have tried converting it myself only to fail. So was wondering if anyone could convert this into a strategy that could be automated with buttons to arm short and arm long. Buy long conditions on think script are "buysignal" and the short side entry conditions to buy are "buysignal1"

    here's the think script code

    input AtrMult = .7;
    input nATR = 4;
    input AvgType = AverageType.HULL;
    input PaintBars = yes;
    input showsignals = yes;
    #def
    def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
    def UP = HL2 + (AtrMult * ATR);
    def DN = HL2 + (-AtrMult * ATR);
    def ST = if close < ST[1] then UP else DN;
    def Vinculum = ST;
    def plotlong = if ST crosses below close then 1 else 0;
    def plotshort = if ST crosses above close then 1 else 0;

    plots
    plot x = plotlong;
    Alert (plotlong, Sound.Ring);
    x.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_UP);
    AssignPriceColor(if x then Color.WHITE else Color.CYAN);

    plot y = plotshort;
    Alert (Vinculum, Sound.Ring);
    y.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_DOWN);
    AssignPriceColor(if x then Color.CYAN else Color.WHITE);

    x.AssignValueColor(if close < ST then Color.RED else Color.CYAN);
    AssignPriceColor(if PaintBars and close < ST

    then Color.RED

    else if PaintBars and close > ST

    then Color.GREEN
    else Color.CURRENT);

    x.SetHiding(!showsignals);
    y.SetHiding(!showsignals);



    def ATR1 = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
    def UP1 = HL2 + (AtrMult * ATR1);
    def DN1 = HL2 + (-AtrMult * ATR1);
    def ST1 = if close < ST[1] then UP1 else DN1;

    def trendChangeUp = ST1 crosses above ST[1];
    def closeHigherAfterTrendChange = close > open and close[1] > open[1];
    def trendIsUp = ST1 > ST[1];

    plot BuySignal = trendChangeUp and closeHigherAfterTrendChange and trendIsUp;
    BuySignal.SetPaintingStrategy(PaintingStrategy.BOO LEAN_ARROW_UP);
    BuySignal.SetDefaultColor(Color.GREEN);
    BuySignal.SetLineWeight(2);

    ##### down #####



    def ATR2 = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
    def UP2 = HL2 + (AtrMult * ATR2);
    def DN2 = HL2 + (-AtrMult * ATR2);
    def ST2 = if close > ST[1] then dn2 else up2;

    def trendChangedn = ST2 crosses below ST[1];
    def closelowerAfterTrendChange = close < open and close[1] < open[1];
    def trendIsdn = ST2 < ST[1];

    plot BuySignal1 = trendChangedn and closelowerAfterTrendChange and trendIsdn;
    BuySignal1.SetPaintingStrategy(PaintingStrategy.BO OLEAN_ARROW_down);
    BuySignal1.SetDefaultColor(Color.red);
    BuySignal1.SetLineWeight(2);​
    If you want, you can PM me on our discord channel and I can take a look. But you must be aware that I'm not doing this for free.
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    Comment


      #3
      Hello Dalton8883,

      Thank you for your post.

      Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services or one on one educational support in our NinjaScript Support department. This is so that we can maintain a high level of service for all of our clients as well as our associates.

      That said, through email or on the forum we are happy to answer any questions you may have about NinjaScript if you decide to code this yourself. I understand you have already tried to make this conversion; if you choose to continue working on it and have questions we are happy to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

      You can also contact a professional NinjaScript Consultant, such as sidlercom80 who has already reached out, who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team to follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.

      Otherwise, this thread will remain open for any members of the NinjaTrader forum community to reach out and help if they'd like.

      Please let me know if I may be of further assistance.​

      Comment


        #4
        Dalton8883 Thank you for wasting my time and not even having the decency to let me know you are not interested.
        sidlercom80
        NinjaTrader Ecosystem Vendor - Sidi Trading

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        86 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        150 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        79 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        52 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        59 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X