NexusFi: Find Your Edge


Home Menu

 





Convert pinescript to easylenguaje


Discussion in EasyLanguage Programming

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




 
Search this Thread

Convert pinescript to easylenguaje

  #1 (permalink)
doko94
Mulege, Baja California Sur
 
Posts: 4 since Nov 2022
Thanks Given: 0
Thanks Received: 1

Hi, I would like to convert this code to easy lenguaje
I have been backtesting in tradingview, no repaints, I would like some help to convert to easylenguaje for get more data

The code is this
strategy("V Bottom/Top Pattern [Misu]", shorttitle="V pattern [Misu]", overlay=true, initial_capital=50000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// import Fontiramisu/fontLib/80 as fontilab
import Fontiramisu/fontilab/8 as fontilab


// -------- Find dev pivots ---------- [
// -- Var user input --
var devTooltip = "Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot."
var depthTooltip = "The minimum number of bars that will be taken into account when analyzing pivots."
thresholdMultiplier = input.float(title="Deviation", defval=3.1, step=0.1, minval=0, tooltip=devTooltip, group="Pivot")
depth = input.int(title="Depth", defval=8, minval=1, tooltip=depthTooltip, group="Pivot")

// Prepare pivot variables
var line lineLast = na
var int iLast = 0 // Index last
var int iPrev = 0 // Index previous
var float pLast = 0 // Price last
var float pLastHigh = 0 // Price last
var float pLastLow = 0 // Price last
var isHighLast = false // If false then the last pivot was a pivot low
isPivotUpdate = false


// Get pivot information from dev pivot finding function
[dupLineLast, dupIsHighLast, dupIPrev, dupILast, dupPLast, dupPLastHigh, dupPLastLow] =
fontilab.getDeviationPivots(thresholdMultiplier, depth, lineLast, isHighLast, iLast, pLast, true, close, high, low)

if not na(dupIsHighLast)
lineLast := dupLineLast
isHighLast := dupIsHighLast
iPrev := dupIPrev
iLast := dupILast
pLast := dupPLast
pLastHigh := dupPLastHigh
pLastLow := dupPLastLow
isPivotUpdate := true

// Plot.
// Get last Pivots.
var highP = 0.0
var lowP = 0.0
var midP = 0.0
highP := isHighLast ? pLast : highP
lowP := not isHighLast ? pLast : lowP
midP := (highP + lowP)/2


// ] -------- Input Vars --------------- [.
breakoutTypeConf = input.string("Mid Pivot", title="Confirmation Type", options=["At First Break", "Mid Pivot", "Opposit Pivot", "No Confirmation"], group="Signal Type Confirmation")
lenghtSizeAvgBody = input.int(9, title="Lenght Avg Body", group="Breakouts Settings")
firstBreakoutFactor = input.float(0.2, step=0.1, title="First Breakout Factor", tooltip="Factor used to validate the first breakout of the V pattern", group="Breakouts Settings")
confBreakoutFactor = input.float(1.2, step=0.1, title="Confirmation Breakout Factor", tooltip="Factor used to validate the confirmation breakout of the V pattern", group="Breakouts Settings")
maxNbBarsValidV = input.int(11, title="Max Bars Confirmation", group="Timing Confirmation")

// ] -------- Logical Vars ------------- [
var _isVbottomPot = false
var _isVtopPot = false
_isVbottom = false
_isVtop = false
lastLow = 0.0
indexLow = 0
lastHigh = 0.0
indexHigh = 0
// Confirm V pattern vars.
var lHighVtopPot = 0.0
var lLowVbotPot = 0.0
var nbBarLVtopPot = 0
var nbBarLVbotPot = 0
var breakLevelVbotPot = 0.0
var breakLevelVtopPot = 0.0

// ] -------- Util Functions ----------- [
// Cond Vars.
_bodyHi = math.max(close, open)
_bodyLo = math.min(close, open)
_body = _bodyHi - _bodyLo
_bodyAvg = ta.ema(_body, lenghtSizeAvgBody)
_longBody = _body > _bodyAvg
_upperWick = high - _bodyHi
_greenBody = open < close
_redBody = open > close
// COND: Potential V pattern.
_breakAboveLowP = ta.crossover(close, lowP) and _body > _bodyAvg * firstBreakoutFactor
_breakUnderHighP = ta.crossunder(close, highP) and _body > _bodyAvg * firstBreakoutFactor
// Crossing Vars.
breakLevelVbotPot := ta.crossunder(close, lowP) ? lowP : breakLevelVbotPot
breakLevelVtopPot := ta.crossover(close, highP) ? highP : breakLevelVtopPot

// @function to get last high/low (handle multiple rsiOver in a row)
getIndexHighLowFromNbCandles(bool isLong, int nbCandles) =>
highLow = isLong ? low : high
indexHighLows = 0
// indexHighLow = 0
for counter = 1 to nbCandles + 10
if isLong
if low[counter] < highLow
highLow := low[counter]
indexHighLows := counter
else
if high[counter] > highLow
highLow := high[counter]
indexHighLows := counter
indexHighLows


isWickCrossPattern (src, isCrossUp) =>
isCross = false
if isCrossUp
isCross := _bodyHi < src and src < high
else
isCross := low < src and src < _bodyLo
isCross


getBreakoutTypeConf(type, isVtop) =>
switch type
"No Confirmation" => isVtop ? highP : lowP
"Opposit Pivot" => isVtop ? lowP : highP
"Mid Pivot" => midP
"At First Break" => isVtop ? breakLevelVtopPot : breakLevelVbotPot

isPivotChanged (oldMidP) =>
midP != oldMidP

// ] -------- Logical Script ----------- [
// -----

// Calculate.
lastLowDup = fontilab.getHighLowFromNbCandles(true, 10)
indexLowDup = getIndexHighLowFromNbCandles(true, 10)
lastHighDup = fontilab.getHighLowFromNbCandles(false, 10)
indexHighDup = getIndexHighLowFromNbCandles(false, 10)

if _breakAboveLowP
lastLow := lastLowDup
indexLow := indexLowDup
_isVbottomPot := true
lLowVbotPot := lastLow
else if _breakUnderHighP
lastHigh := lastHighDup
indexHigh := indexHighDup
_isVtopPot := true
lHighVtopPot := lastHigh

// Confirm potential V bot pattern.
isBreakBarAvg = breakoutTypeConf != "No Confirmation" ? _body > _bodyAvg * confBreakoutFactor : true
vBotConfSrc = getBreakoutTypeConf(breakoutTypeConf, false)
_isVbottom := _isVbottomPot and ta.crossover(close, vBotConfSrc) and isBreakBarAvg
if _isVbottomPot
// Cond V pot invalidated or finished.
if not _isVbottom and low >= lLowVbotPot and nbBarLVbotPot <= maxNbBarsValidV
nbBarLVbotPot := nbBarLVbotPot + 1
else
_isVbottomPot := false
nbBarLVbotPot := 0
// Confirm potential V top pattern.
vTopConfSrc = getBreakoutTypeConf(breakoutTypeConf, true)
_isVtop := _isVtopPot and ta.crossunder(close, vTopConfSrc) and isBreakBarAvg
if _isVtopPot
// Cond V pot invalidated or finished.
if not _isVtop and high <= lHighVtopPot and nbBarLVtopPot <= maxNbBarsValidV
nbBarLVtopPot := nbBarLVtopPot + 1
else // reinit for next V patter.
_isVtopPot := false
nbBarLVtopPot := 0

// -----
// BUY / SELL COND.
buyCond = _isVbottom
sellCond = _isVtop

// ] -------- Strategy Part ------------ [
if buyCond
strategy.entry("L", strategy.long, alert_message="Buy Signal")

if sellCond
strategy.entry("S", strategy.short, alert_message="Sell Signal")

// ] -------- Plot Part & Alerts ------- [
midPPlot = plot(midP, title='Mid Pivot', linewidth=1, color=color.yellow, display=display.none)
highPlot = plot(highP, title='High Pivot', linewidth=1, color=color.red, display=display.none)
lowPlot = plot(lowP, title='Low Pivot', linewidth=1, color=color.green, display=display.none)

if buyCond
label.new(x = bar_index, y = low - (ta.atr(30) * 0.2), xloc = xloc.bar_index, text = "V", style = label.style_label_up, color = color.green, size = size.small, textcolor = color.white, textalign = text.align_center)
else if sellCond
label.new(x = bar_index, y = high + (ta.atr(30) * 0.2), xloc = xloc.bar_index, text = "V", style = label.style_label_down, color = color.red, size = size.small, textcolor = color.white, textalign = text.align_center)
if _breakAboveLowP
label.new(x = bar_index - indexLowDup, y = low[indexLowDup] - (ta.atr(30) * 0.2), xloc = xloc.bar_index, text = "Vp", style = label.style_label_up, color = color.new(color.green, 70), size = size.small, textcolor = color.white, textalign = text.align_center)
else if _breakUnderHighP
label.new(x = bar_index - indexHighDup, y = high[indexHighDup] + (ta.atr(30) * 0.2), xloc = xloc.bar_index, text = "Vp", style = label.style_label_down, color = color.new(color.red, 70), size = size.small, textcolor = color.white, textalign = text.align_center)

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Cheap historycal L1 data for stocks
Stocks and ETFs
What broker to use for trading palladium futures
Commodities
 
  #2 (permalink)
 
syswizard's Avatar
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
Posts: 344 since Jan 2019
Thanks Given: 20
Thanks Received: 146

That code cannot be converted until you have the source code for all of the functions that are called.
For instance: getDeviationPivots

Reply With Quote




Last Updated on November 9, 2022


© 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