Let us discuss about the scrip codes, strategies, custom indicators and lot more that can be done using PINE SCRIPT available in trading view and share our thoughts and opinions to other users.
Any one help me in writing this in pine script code,
(Latest high - Latest low) > (1 day ago high - 1 day ago low) and
(Latest high - latest low) > (2 days ago high - 2 days ago low) and
(Latest high - latest low) > (3 days ago high - 3 days ago low) and
(Latest high - latest low) > (4 days ago high - 4 days ago low) and
(Latest high - latest low) > (5 days ago high - 5 days ago low) and
(Latest high - latest low) > (6 days ago high - 6 days ago low) and
(Latest high - latest low) > (7 days ago high - 7 days ago low) and
Latest close > latest open and
Latest close > 1 day ago close and
Weekly close > weekly open and
Monthly close > monthly open and
1 day ago volume > 100000 and
Latest SMA (close,20) > latest SMA (close,50) and
Latest SMA (close,50) > latest SMA ( close,200 ) .
I am continuously getting syntax errors like this,
2:16:57 PM | ‘Untitled script’ opened |
---|---|
2:17:32 PM | Compiling… |
2:17:33 PM | ‘My strategy’ saved. |
2:18:25 PM | Compiling… |
2:18:26 PM | Done. |
2:18:26 PM | Added to chart. |
3:35:38 PM | Compiling… |
3:35:39 PM | Error at 8:46 Syntax error at input ‘end of line without line continuation’ |
3:35:39 PM | ‘My strategy’ saved. |
3:44:50 PM | Compiling… |
3:44:50 PM | Error at 8:0 Syntax error at input ‘end of line without line continuation’. |
3:44:50 PM | ‘My strategy’ saved. |
3:45:24 PM | Compiling… |
3:45:25 PM | Error at 14:0 required (…)+ loop did not match anything at character ‘’ |
3:45:25 PM | ‘My strategy’ saved. |
3:47:58 PM | Compiling… |
3:47:59 PM | Error at 8:0 Syntax error at input ‘end of line without line continuation’. |
3:47:59 PM | ‘My strategy’ saved. |
3:47:59 PM | Converting… |
3:47:59 PM | Conversion failed, reason: Pine source is incorrect. line 8: Syntax error at input ‘end of line without line continuation’. |
3:48:51 PM | Script has been deleted |
3:49:37 PM | Compiling… |
3:49:38 PM | Error at 5:0 Syntax error at input ‘end of line without line continuation’. |
I tried this, but its not working.
//@version=5
strategy(“My Strategy”, overlay=true)
// Parameters
var float stop_loss = na
var float take_profit = na
// Conditions
var bool cond1 = (high - low) > (high[1] - low[1])
var bool cond2 = (high - low) > (high[2] - low[2])
var bool cond3 = (high - low) > (high[3] - low[3])
var bool cond4 = (high - low) > (high[4] - low[4])
var bool cond5 = (high - low) > (high[5] - low[5])
var bool cond6 = (high - low) > (high[6] - low[6])
var bool cond7 = (high - low) > (high[7] - low[7])
var bool cond8 = close > open
var bool cond9 = close > close[1]
var bool cond10 = close > open and timeframe.isweekly ? close > open : true
var bool cond11 = close > open and timeframe.ismonthly ? close > open : true
var bool cond12 = volume[1] > 100000
var bool cond13 = ta.sma(close, 20) > ta.sma(close, 50)
var bool cond14 = ta.sma(close, 50) > ta.sma(close, 200)
// Entry and Exit Conditions
if (cond1 and cond2 and cond3 and cond4 and cond5 and cond6 and cond7 and cond8 and cond9 and cond10 and cond11 and cond12 and cond13 and cond14)
strategy.entry(“Buy”, strategy.long)
if (strategy.position_size > 0)
strategy.exit(“Take Profit/Stop Loss”, “Buy”, profit=take_profit, loss=stop_loss)
// Stop Loss and Take Profit Calculation
if (strategy.position_size == 1)
stop_loss := strategy.position_avg_price * 0.97
take_profit := strategy.position_avg_price * 1.03 * 3