unltimo Z-Score
unltimo Z-Score
// // Debug last Trade Was Loss "It Swithes from 0 to 1 everytime the entire strip
changes from win to loss"
// if strategy.closedtrades != strategy.closedtrades[1]
// log.info(str.tostring(lastTradeWasLoss), "lastTradeWasLoss")
// // End checking if last trade was lost
// // Counter
var countLostTrades = 0
var countWonTrades = 0
if (strategy.losstrades[0] > strategy.losstrades[1])
countLostTrades := countLostTrades - 1
else if (strategy.wintrades[0] > strategy.wintrades[1])
countLostTrades := 0
if (strategy.wintrades[0] > strategy.wintrades[1])
countWonTrades := countWonTrades + 1
else if (strategy.losstrades[0] > strategy.losstrades[1])
countWonTrades := 0
plotshape(MM_Method == 13 ? countLostTrades : na, title="Count Lost Trades",
color=color.red)
plotshape(MM_Method == 13 ? countWonTrades : na, title="Count Won Trades",
color=color.green)
// // Start Strips Win/Loss Max Trades Plotter. It returns the maximum of the
strip.
//////////////////////// Start Start End Bar Index Returns the bar index at the
beginning/end of the strip. Not Needed "keep commented". ////////////////////////
// plot(bar_index, title="Bar Index")
maxStripWonTrades = 0
if countLostTrades[0] < 0 and countLostTrades[1] == 0
maxStripWonTrades := countWonTrades[1]
plot(maxStripWonTrades, title="Max Strip Won Trades")
plotshape(MM_Method == 13 and countLostTrades[0] < 0 and countLostTrades[1] == 0 ?
countLostTrades[0] < 0 and countLostTrades[1] == 0 : na, title="Start Bar Index
Plotshape", color=color.green, size=size.normal)
maxStripLostTrades = 0
if countWonTrades[0] > 0 and countWonTrades[1] == 0
maxStripLostTrades := countLostTrades[1]
plot(maxStripLostTrades, title="Max Strip Lost Trades")
plotshape(MM_Method == 13 and countWonTrades[0] > 0 and countWonTrades[1] == 0 ?
countWonTrades[0] > 0 and countWonTrades[1] == 0 : na, title="End Bar Index
Plotshape", color=color.red, size=size.normal)
// // // Debug Start Strips Win/Loss Max Trades Plotter.
if MM_Method == 13 and maxStripWonTrades != 0
log.info(str.tostring(maxStripWonTrades), "Max Strip Won Trades")
// log.info("\nMax Strip Won Trades : {0}" , str.tostring(maxStripWonTrades))
// More detailed logs !!!
if MM_Method == 13 and maxStripLostTrades != 0
log.info(str.tostring(maxStripLostTrades), "Max Strip Lost Trades")
// log.info("\nMax Strip Lost Trades : {0}" , str.tostring(maxStripLostTrades))
// // End Strips Win/Loss Max Trades Plotter. It returns the maximum of the strip.
// More detailed logs !!!
//and MaxPositiveStrips != 0
posSize = 0.0
if (MM_Method == 13) // Monetario In
Percentuale Al Balance Win/Loss Incremented/Decremented (Imposta Input
EntryCapitalPercent)
posSize := EntryBalancePercentIncDec
// // Qui se voglio provare lo swing della posizone per vedere se chiude tutte le
posizioni. Funziona !!!, con questo codice chiude tutto specialmente al cambio
della size "va bene" !!!
// // Condizioni Di Swing Short (Commentare il: Condizione Chiusura Long E
decommentare Condizioni Di Swing Short Per fare questo test!!! )
shortCondition = ta.crossunder(ta.sma(close, 7), ta.sma(close, 12))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short, qty=posSize)
// Monitoraggio posizione
bought = strategy.position_size[0]> strategy.position_size[1]
Close_TP = false
Close_TP := strategy.position_size[1] - strategy.position_size[0] and
strategy.position_size[1] != 0 and strategy.position_size[0] != 0
///////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
// Table Inputs
fattoreArrotondamento = input.int(1, "Fattore di arrotondamento",options =
[1,10,100,1000,10000,100000, 1000000, 10000000])
posizione = input.string("bottom_right", "posizione tabella", ["bottom_left",
"bottom_center", "bottom_right", "middle_left", "middle_center", "middle_right",
"top_left", "top_center" ,"top_right"])
coloreBarreBullish = input.color(color.rgb(47, 159, 68), "Colore celle bullish")
coloreBarreBearish = input.color(color.rgb(227, 65, 65), "Colore celle bearish")
coloreSfondoTabella = input.color(color.rgb(53, 61, 68), "Colore sfondo tabella")
coloreEtichetteSfondo = input.color(color.rgb(19, 50, 70), "Colore sfondo
etichetta")
coloreEtichetteTesto = input.color(color.rgb(255, 255, 255), "Colore testo
etichetta")
dimensioneTesto = input.string("small", "Dimensione Carattere", options=["tiny",
"small", "normal", "large", "huge"])
if maxStripLostTrades != 0
array.push(arrayMaxStripLostTrades, maxStripLostTrades)
if maxStripLostTrades != 0
array.push(arrayTotalStrips, maxStripLostTrades) // fare il merge di won and
lost che non esiste. sopra nel codice li ottengo semplicemente perchè li ottengo il
totle in modo separato !!!
// // Loop all the array size and display all the lenght on the screen with
table.cell "arrayMaxStripWonTrades"
// for i=0 to array.size(arrayMaxStripWonTrades)-1
// table.cell(tabellaInfo, i+1, 0, str.tostring(i), text_color =
coloreEtichetteTesto, text_size = dimensioneTesto, text_halign=text.align_center)
table.cell(tabellaInfo, 2, 0, str.tostring(array.size(arrayMaxStripWonTrades)),
text_color = coloreEtichetteTesto, text_size = dimensioneTesto,
text_halign=text.align_center)
for i=0 to 0
table.cell(tabellaInfo, i+1, 0, str.tostring(arrayMaxStripWonTrades),
text_color = coloreEtichetteTesto, text_size = dimensioneTesto,
text_halign=text.align_center)
// // Loop all the array size and display all the lenght on the screen with
table.cell "arrayMaxStripLostTrades"
// for i=0 to array.size(arrayMaxStripLostTrades)-1
// table.cell(tabellaInfo, i+1, 1, str.tostring(i), text_color =
coloreEtichetteTesto, text_size = dimensioneTesto, text_halign=text.align_center)
table.cell(tabellaInfo, 2, 1, str.tostring(array.size(arrayMaxStripLostTrades)),
text_color = coloreEtichetteTesto, text_size = dimensioneTesto,
text_halign=text.align_center)
for i=0 to 0
table.cell(tabellaInfo, i+1, 1, str.tostring(arrayMaxStripLostTrades),
text_color = coloreEtichetteTesto, text_size = dimensioneTesto,
text_halign=text.align_center)
// // Loop all the array size and display all the lenght on the screen with
table.cell "arrayTotalStrips"
// for i=0 to array.size(arrayTotalStrips)-1
// table.cell(tabellaInfo, i+1, 2, str.tostring(i), text_color =
coloreEtichetteTesto, text_size = dimensioneTesto, text_halign=text.align_center
// for i=0 to 0
// table.cell(tabellaInfo, i+1, 2, str.tostring(arrayMaxStripWonTrades) +
str.tostring(arrayMaxStripLostTrades) , text_color = coloreEtichetteTesto,
text_size = dimensioneTesto, text_halign=text.align_center)
labelChange = ""
if inPosition == true
labelChange := countWonTrades == MaxPositiveStrips ? "Change_Size: " +
str.tostring(EntryCapitalPercentZScorePositiveStrips) :
countLostTrades == - MaxNegativeStrips ? "Change_Size: " +
str.tostring(EntryCapitalPercentZScoreNegativeStrips) :
"Change_Size: " + str.tostring(EntryCapitalPercentZScore)
label.new(bar_index, na, text=labelChange, yloc=yloc.abovebar, color=color.red)
// Sistemazione label //
// Se c'è lo swing di posizione il codice non entra con la size giusta.
// Controllare tutto il codice che funziona bene con le size e le label, ATTENZIONE
a volte le label non dicono la verità, al momento se metto strips a 0 entra con:
EntryCapitalPercentZScore