Parabolic Sar trading system code ..for “a new life” (easy and profitable) – Tradingview e ProrealTime coding

Just a simple Parabolic Sar to make your life easy..

PROREALTIME TRADING SYSTEM CODE// Definizione dei parametri del codice
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate

// Condizioni per entrare su posizioni long
indicator1 = SAR[0.02,0.02,0.2]
c1 = (close CROSSES OVER indicator1)
c2 = (close >= DOpen(0))
// c2 is “green bar” condition
c3 = (close >= DHigh(1))

IF c1 AND c2 AND c3 THEN
BUY 20000 CASH AT MARKET
ENDIF

// Condizioni per uscire da posizioni long
indicator2 = SAR[0.02,0.02,0.2]
c4 = (close CROSSES UNDER indicator2)
indicator3 = SAR[0.02,0.02,0.2]
c5 = (close <= indicator3[1])

IF c4 AND c5 THEN
SELL AT MARKET
ENDIF

// no other money management

PROREALTIME SCREENER (you can use it once a week, for instance, not everyday)

indicator1 = SAR[0.02,0.02,0.2]
// you have to write every cicle, since Proscreener doesn’t “read” cycle instruction “for.. to”

// giorno oggi
C1 = (close CROSSES OVER indicator1)
c2 = (close > high[1])
c3 = (close > open)
c4 = (c1 and c2 and c3)
if c4 then
i = 0
endif
// ieri
C10 = (close[1] CROSSES OVER indicator1[1])
c20 = (close[1] > high[2])
c30 = (close[1] > open[1])
c40 = (c10 and c20 and c30)
if c40 then
i = 1
endif
// 2 giorni fa
C100 = (close[2] CROSSES OVER indicator1[2])
c200 = (close[2] > high[3])
c300 = (close[2] > open[2])
c400 = (c100 and c200 and c300)
if c400 then
i = 2
endif
// 3 giorni fa
C1000 = (close[3] CROSSES OVER indicator1[3])
c2000 = (close[3] > high[4])
c3000 = (close[3] > open[3])
c4000 = (c1000 and c2000 and c3000)
if c4000 then
i = 3
endif
// 4 giorni fa
C10000 = (close[4] CROSSES OVER indicator1[4])
c20000 = (close[4] > high[5])
c30000 = (close[4] > open[4])
c40000 = (c10000 and c20000 and c30000)
if c40000 then
i = 4
endif
// 5 giorni fa
C100000 = (close[5] CROSSES OVER indicator1[5])
c200000 = (close[5] > high[6])
c300000 = (close[5] > open[5])
c400000 = (c100000 and c200000 and c300000)
if c400000 then
i = 5
endif
// 6 giorni fa
C1000000 = (close[6] CROSSES OVER indicator1[6])
c2000000 = (close[6] > high[7])
c3000000 = (close[6] > open[6])
c4000000 = (c1000000 and c2000000 and c3000000)
if c4000000 then
i = 6
endif
SCREENER[c4 or c40 or c400 or c4000 or c40000 or c400000 or c4000000] (i as “day”, volume as “volume”)

TRADINGVIEW TRADING SYSTEM

//@version=5
// versione 20 redatta 1702 2022
strategy(‘psar_newlife_2023’, calc_on_order_fills=false, calc_on_every_tick=true, commission_type=strategy.commission.percent, commission_value=0.3, overlay=true, default_qty_type=strategy.cash, default_qty_value=20000, initial_capital=20000)
// === INPUT BACKTEST RANGE ===
fromMonth = input.int (defval = 1, title = “From Month”, minval = 1, maxval = 12)
fromDay = input.int (defval = 1, title = “From Day”, minval = 1,maxval = 31)
fromYear = input.int(defval = 2017, title = “From Year”, minval = 1970)
thruMonth = input.int(defval = 1, title = “Thru Month”, minval = 1, maxval = 12)
thruDay = input.int(defval = 1, title = “Thru Day”, minval = 1, maxval = 31)
thruYear = input.int(defval = 2112, title = “Thru Year”, minval = 1970)
// === FUNCTION EXAMPLE limit for backtest ===
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function “within window of time”

//INDICATORI
startsar = input(0.02, “Inizio Sar”)
increment = input(0.02, “Incremento Sar”)
maximum = input(0.2, “Max Sar”)
mysar = ta.sar(startsar, increment, maximum)
plot(mysar, “ParabolicSAR”, linewidth=2, style=plot.style_cross, color=#2962FF)
//sistema (come prorealtime)
c1 = ta.crossover(close,mysar)
c2 = close > open
c3 = close > high[1]
entryl = (c1 and c2 and c3)
strategy.entry(‘Long’, strategy.long, when=entryl)
c4 = ta.crossunder(close,mysar)
c5 = (close < mysar[1])
exit = (c4 and c5)
strategy.close(‘Long’, when=exit)
// altri disegni
mysma = ta.sma(ohlc4,20)
plot(mysma, title=’Media mob’, color = color.rgb(238, 0, 255), linewidth=1, style=plot.style_line)
//Go Saucius Go!!

————————————————————————–

- / 5
Grazie per aver votato!