cop2
cop2
type Vol
array<float> Total
array<float> Green
array<float> Red
array<float> SCR
Volume = Vol.new(
array.new_float(),
array.new_float(),
array.new_float(),
array.new_float()
//----- { SL Calculation
// -- ATR
x2 = low - ta.rma(ta.tr(true), 14) * 1.5
xz = ta.rma(ta.tr(true), 14) * 1.5 + high
longDiffSL2 = math.abs(close - xz)
longDiffSL = math.abs(close - x2)
// }
Adj = volAdj(30)
VolCal(Index,Sync) =>
Bars = math.abs(Index - Sync)
for i = 0 to Bars -1
Volume.SCR.push(close[i])
for i = 0 to Volume.SCR.size() -1
Volume.Total.push(volume[i])
if ta.change(fixnan(PH)) != 0
UpdatedHigh := PH
phActive := true
HighIndex := Sync - period
if ta.change(fixnan(PL)) != 0
UpdatedLow := PL
plActive := true
LowIndex := Sync - period
// LONG
if ScrHigh > UpdatedHigh and phActive
BUY := true
phActive := false
//Sell
if ScrLow < UpdatedLow and plActive
SELL := true
plActive := false
// lets Draw
if true
if TradeFire and not TradeisON
TP := switch
Long => close + (RR1 * longDiffSL)
Short => close - (RR1 * longDiffSL2)
SL := switch
Long => close - longDiffSL
Short => close + longDiffSL2
TradeisON:= true
if true
line.new(bar_index,
Long ? high : low,
bar_index,
TP,
width=2,
color = TAIL,
style= line.style_dashed)
tpLine:= line.new(bar_index,
TP,
bar_index+2,
TP,
style= line.style_dashed,
color = TAIL
)
if ShowSL
SLLine:= line.new(bar_index,
SL,
bar_index+2,
SL,
style= line.style_dashed,
color = RED
)
LAB:=label.new(bar_index,
TP,
"Target",
color = TAIL,
style= label.style_label_left,
size=size.small,
textcolor = color.white
)
if TradeisON
line.set_x2(tpLine,bar_index)
label.set_x(LAB,bar_index+1)
if ShowSL
line.set_x2(SLLine,bar_index)
// where is my table ?!
var tb = table.new(position.top_right, 3, 3,
bgcolor= color.new(color.gray,80))
if barstate.islast
alertcondition(Long,"BUY")
alertcondition(Short,"Sell")
//@version=5
strategy('RMI ADPRO Strategy', overlay=true, max_labels_count=500,
currency=currency.USD)
if p_mom
positive := true
negative := false
if n_mom
positive := false
negative := true
Band = _Band(30)
// Long Position: Full amount on green (buy) signal, close on red (sell) signal
if positive and not positive[1]
// Close any existing long positions (including grid positions) to ensure we
can open a new "Long" position
strategy.close_all(comment="Close All Before Long")
strategy.entry("Long", strategy.long, qty=long_qty)
// Debug label to confirm the long position entry attempt
label.new(bar_index, close, "Long Entry Attempt: " + str.tostring(long_qty) + "
contracts", color=color.green, style=label.style_label_down, textcolor=color.white)
// Grid Bot: On red (sell) signal, place 30 grid lines, 2.5% apart
var float grid_base_price = 0.0
var float[] grid_prices = array.new_float(0)
var line[] grid_lines_array = array.new_line(0) // Array to store grid lines for
removal
// Close all grid positions and remove grid lines when signal changes to positive
if positive and not positive[1]
f_removeLines()
for i = 0 to grid_lines - 1
strategy.close("Grid" + str.tostring(i), comment="Close Grid " +
str.tostring(i))