Conversion from a Pine code using SMAs for long entry/exit

Forums ProRealTime English forum ProBuilder support Conversion from a Pine code using SMAs for long entry/exit

Viewing 1 post (of 1 total)
  • #223322

    strategy(“SmartLong”, overlay=true,
    initial_capital = 5000,
    currency = currency.USD,
    commission_type = strategy.commission.cash_per_order,
    commission_value = 2,
    slippage = 0,
    default_qty_value = 100,
    default_qty_type = strategy.percent_of_equity,
    process_orders_on_close = true)
    Length = input(20)
    IndexRef =input(“QQQ”)
    maclose = ta.sma(close, Length)
    avgvol = ta.sma(volume, Length)
    priceIsAboveMaPositionDay = close > ta.sma(close, Length) and close>open and close[1]>open[1] and close[2]>open[2] and close[3]>open[3]
    QQQPriceIsAboveMa = request.security(IndexRef, “D”, priceIsAboveMaPositionDay)
    longLossPerc = input.float(3, title=”Long Stop Loss (%)”,
    minval=0.0, step=0.1) * 0.01
    longStopPrice = strategy.position_avg_price * (1 – longLossPerc)
    // Plot stop loss values for confirmation
    plot(strategy.position_size > 0 ? longStopPrice : na,
    color=color.red, style=plot.style_cross,
    linewidth=2, title=”Long Stop Loss”)
    //////////////////////////////////////////////////////////////

    // Calculate start/end date and time condition
    startDate = input.time(timestamp(“2019-01-01T00:00:00”), “StartDate”)
    finishDate = input.time(timestamp(“2023-12-31T00:00:00”), “FinishDate”)

    time_cond = time >= startDate and time <= finishDate ////////////////////////////////////////////////////////////// if ((ta.crossover(close, maclose) or close>maclose ) and close>close[1] and close>close[5] and time_cond and QQQPriceIsAboveMa)
    strategy.entry(“LE”, strategy.long, comment=”LE”)
    if (ta.crossunder(close, maclose) or close 0 and time_cond
    strategy.exit(“XL STP”, stop=longStopPrice)
    if (not time_cond)
    strategy.close_all()
    strategy.cancel_all()

Viewing 1 post (of 1 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login