NexusFi: Find Your Edge


Home Menu

 





convert strategy


Discussion in NinjaTrader

Updated
    1. trending_up 88 views
    2. thumb_up 1 thanks given
    3. group 1 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

convert strategy

  #1 (permalink)
ilhanDnz
St Loup de Varennes France
 
Posts: 3 since Mar 2024
Thanks Given: 0
Thanks Received: 1

I would convert a strategy tradingview to ninjascript

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 5,982 since Sep 2015
Thanks Given: 15,510
Thanks Received: 15,436


ilhanDnz View Post
I would convert a strategy tradingview to ninjascript

Hi ilhanDnz, welcome.

Just to clarify your post, are you looking for help to convert a tradingview strategy to ninjascript, or are you offering help to do so?

Reply With Quote
  #3 (permalink)
ilhanDnz
St Loup de Varennes France
 
Posts: 3 since Mar 2024
Thanks Given: 0
Thanks Received: 1



xplorer View Post
Hi ilhanDnz, welcome.

Just to clarify your post, are you looking for help to convert a tradingview strategy to ninjascript, or are you offering help to do so?

I looking for help

Reply With Quote
  #4 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 5,982 since Sep 2015
Thanks Given: 15,510
Thanks Received: 15,436


ilhanDnz View Post
I looking for help

Ok thanks for clarifying.

I am not familiar with TradingView personally, but if you explain exactly what you need help with, perhaps other users can assist.

I understand you want a trandingview strategy converted to ninjascript. Are you able to share the strategy, for example?

Or is it more a case that you want to hire a developer?

Reply With Quote
  #5 (permalink)
ilhanDnz
St Loup de Varennes France
 
Posts: 3 since Mar 2024
Thanks Given: 0
Thanks Received: 1


xplorer View Post
Ok thanks for clarifying.

I am not familiar with TradingView personally, but if you explain exactly what you need help with, perhaps other users can assist.

I understand you want a trandingview strategy converted to ninjascript. Are you able to share the strategy, for example?

Or is it more a case that you want to hire a developer?


just convert it to use it automatically on nt
This is the strategy :


//@version=3
strategy(title = "Open Close Cross Strategy R5.1 revised by JustUncleL", shorttitle = "OCC Strategy R5.1", overlay = true,
pyramiding = 0, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, calc_on_every_tick=false)

// === INPUTS ===
useRes = input(defval = true, title = "Use Alternate Resolution?")
intRes = input(defval = 5, title = "Multiplier for Alernate Resolution")
stratRes = ismonthly? tostring(interval*intRes,"###M") : isweekly? tostring(interval*intRes,"###W") : isdaily? tostring(interval*intRes,"###D") : isintraday ? tostring(interval*intRes,"####") : '60'
basisType = input(defval = "TMA", title = "MA Type: ", options=["SMA", "EMA", "DEMA", "TEMA", "WMA", "VWMA", "SMMA", "HullMA", "LSMA", "ALMA", "SSMA", "TMA"])
basisLen = input(defval = 10, title = "MA Period", minval = 1)
offsetSigma = input(defval = 6, title = "Offset for LSMA / Sigma for ALMA", minval = 0)
offsetALMA = input(defval = 0.85, title = "Offset for ALMA", minval = 0, step = 0.01)
scolor = input(false, title="Show coloured Bars to indicate Trend?")
delayOffset = input(defval = 11, title = "Delay Open/Close MA (Forces Non-Repainting)", minval = 0, step = 1)
tradeType = input("BOTH", title="What trades should be taken : ", options=["LONG", "SHORT", "BOTH", "NONE"])
// === /INPUTS ===

// Constants colours that include fully non-transparent option.
green100 = #008000FF
lime100 = #00FF00FF
red100 = #FF0000FF
blue100 = #0000FFFF
aqua100 = #00FFFFFF
darkred100 = #8B0000FF
gray100 = #808080FF

// === BASE FUNCTIONS ===
// Returns MA input selection variant, default to SMA if blank or typo.
variant(type, src, len, offSig, offALMA) =>
v1 = sma(src, len) // Simple
v2 = ema(src, len) // Exponential
v3 = 2 * v2 - ema(v2, len) // Double Exponential
v4 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len) // Triple Exponential
v5 = wma(src, len) // Weighted
v6 = vwma(src, len) // Volume Weighted
v7 = 0.0
v7 := na(v7[1]) ? sma(src, len) : (v7[1] * (len - 1) + src) / len // Smoothed
v8 = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) // Hull
v9 = linreg(src, len, offSig) // Least Squares
v10 = alma(src, len, offALMA, offSig) // Arnaud Legoux
v11 = sma(v1,len) // Triangular (extreme smooth)
// SuperSmoother filter
// © 2013 John F. Ehlers
a1 = exp(-1.414*3.14159 / len)
b1 = 2*a1*cos(1.414*3.14159 / len)
c2 = b1
c3 = (-a1)*a1
c1 = 1 - c2 - c3
v12 = 0.0
v12 := c1*(src + nz(src[1])) / 2 + c2*nz(v12[1]) + c3*nz(v12[2])
type=="EMA"?v2 : type=="DEMA"?v3 : type=="TEMA"?v4 : type=="WMA"?v5 : type=="VWMA"?v6 : type=="SMMA"?v7 : type=="HullMA"?v8 : type=="LSMA"?v9 : type=="ALMA"?v10 : type=="TMA"?v11: type=="SSMA"?v12: v1

// security wrapper for repeat calls
reso(exp, use, res) => use ? security(tickerid, res, exp, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) : exp

// === /BASE FUNCTIONS ===

// === SERIES SETUP ===
closeSeries = variant(basisType, close[delayOffset], basisLen, offsetSigma, offsetALMA)
openSeries = variant(basisType, open[delayOffset], basisLen, offsetSigma, offsetALMA)
// === /SERIES ===

// === PLOTTING ===
// Get Alternate resolution Series if selected.
closeSeriesAlt = reso(closeSeries, useRes, stratRes)
openSeriesAlt = reso(openSeries, useRes, stratRes)
//
trendColour = (closeSeriesAlt > openSeriesAlt) ? green : red
bcolour = (closeSeries > openSeriesAlt) ? lime100 : red100
barcolor(scolor?bcolour:na, title = "Bar Colours")
closeP=plot(closeSeriesAlt, title = "Close Series", color = trendColour, linewidth = 2, style = line, transp = 20)
openP=plot(openSeriesAlt, title = "Open Series", color = trendColour, linewidth = 2, style = line, transp = 20)
fill(closeP,openP,color=trendColour,transp=80)
// === /PLOTTING ===

// === ALERT conditions
xlong = crossover(closeSeriesAlt, openSeriesAlt)
xshort = crossunder(closeSeriesAlt, openSeriesAlt)
longCond = xlong // alternative: longCond[1]? false : (xlong or xlong[1]) and close>closeSeriesAlt and close>=open
shortCond = xshort // alternative: shortCond[1]? false : (xshort or xshort[1]) and close<closeSeriesAlt and close<=open
// === /ALERT conditions.
// === STRATEGY ===
// stop loss
slPoints = input(defval = 147, title = "Initial Stop Loss Points (zero to disable)", minval = 0)
tpPoints = input(defval = 10, title = "Initial Target Profit Points (zero for disable)", minval = 0)
// Include bar limiting algorithm
ebar = input(defval = 90000000, title="Number of Bars for Back Testing", minval=0)
dummy = input(false, title="- SET to ZERO for Daily or Longer Timeframes" )
//
// Calculate how many mars since last bar
tdays = (timenow-time)/60000.0 // number of minutes since last bar
tdays := ismonthly? tdays/1440.0/5.0/4.3/interval : isweekly? tdays/1440.0/5.0/interval : isdaily? tdays/1440.0/interval : tdays/interval // number of bars since last bar
//
//set up exit parameters
TP = tpPoints>0?tpPoints:na
SL = slPoints>0?slPoints:na

isTradingHour = hour >= 1 and hour < 13
// Make sure we are within the bar range, Set up entries and exit conditions
if ((ebar==0 or tdays<=ebar) and tradeType!="NONE")
strategy.entry("long", strategy.long, when=longCond==true and tradeType!="SHORT" and isTradingHour)
strategy.entry("short", strategy.short, when=shortCond==true and tradeType!="LONG" and isTradingHour)
strategy.close("long", when = shortCond==true and tradeType=="LONG")
strategy.close("short", when = longCond==true and tradeType=="SHORT")
strategy.exit("XL", from_entry = "long", profit = TP, loss = SL)
strategy.exit("XS", from_entry = "short", profit = TP, loss = SL)

// === /STRATEGY ===
// eof

Reply With Quote
Thanked by:




Last Updated on March 15, 2024


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts