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

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #223322 quote
    rzan61rzan61
    Participant
    New

    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 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)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
rzan61 @rzan61 Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/07/2023
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...