Coding correction for submitted code

Forums ProRealTime English forum ProBuilder support Coding correction for submitted code

  • This topic has 3 replies, 2 voices, and was last updated 11 months ago by avatarJS.
Viewing 4 posts - 1 through 4 (of 4 total)
  • #226795

    Hi,

    Hoping someone might be able to review three lines of code which are apparently in correct, though they look correct

    1 DEFPARAM CumulateOrders = False

    13 Buy 1 Shares AT Market                                   Error appear to be Buy

    18  set stop ploss slosslevel                                   Error appears to be set

    19 set stop %trailing 0.5                                        Error appears to be set

    #226801
    JS

    Hi @Marketpunk

    There is nothing wrong with the code, only I think you are trying to use  this code in an indicator while this code can only be used in (automatic) trading and backtesting…

    #226823

    JS, Thank you. That might be it. Could you advise what the code would be so it can be used as an indicator please as that’s what I was looking for.  The full code supplied was

    DEFPARAM CumulateOrders = False

    MyMACD = MACDline[12,26,9](close)
    MySLine = MACDSignal[12,26,9](close)
    MyHis = MACD[12,26,9](close)
    EMA200 = ExponentialAverage[200](close)

    C1 = MyMACD Crosses Over MySLine AND MyMACD < 0 AND MySLine < 0
    C2 = Close > EMA200
    BuyCondition = C1 AND C2

    IF BuyCondition THEN
    Buy 1 Shares AT Market
    SwingLow = lowest[10](low) // Assuming a 10-bar lookback for swing low
    NearestLevel = Min(SwingLow, EMA200) // Selecting the nearest level to the current price

    slosslevel = Tradeprice – NearestLevel
    set stop ploss slosslevel
    set stop %trailing 0.5
    ENDIF

     

    C3 = MyMACD Crosses Under MySLine AND MyMACD > 0 AND MySLine > 0
    C4 = Close < EMA200
    SellCondition = C3 AND C4

    IF SellCondition THEN
    Sellshort 1 Shares AT Market
    SwingHigh = highest[10](high) // Assuming a 10-bar lookback for swing high
    NearestLevel = Max(SwingHigh, EMA200) // Selecting the nearest level to the current price
    slosslevel = Tradeprice – NearestLevel
    set stop ploss slosslevel
    set stop %trailing 0.5
    ENDIF

    // Take Profit options
    Option1RiskReward = 2 // Adjustable Risk/Reward ratio (e.g., 2 means 2:1)
    Option2TrailStopPercent = 0.5 // Adjustable Trailing Stop loss percentage (e.g., 0.5%)
    NearestStopLoss = 10 // minimum stop distance
    TakeProfitOption1 = NearestLevel + (NearestLevel – NearestStopLoss) * Option1RiskReward

    if (open < TakeProfitOption1 and close > TakeProfitOption1) or (open > TakeProfitOption1 and close < TakeProfitOption1) then
    sell at market
    exitshort at market
    endif

    Thanks for your help.

    #226852
    JS

    Hi MarketPunk,

    In PRT, there is a separation between the creation of systems (ProOrder), indicators (ProBuilder) and screeners (ProScreener).

    The code that you can use in ProBuilder is the basis and this code can also be used in ProOrder and ProScreener, but there is also code that you can only use in a specific module.

    For example, ProOrder has about 60 instructions that can only be used in the ProOrder module (Buy, Sell, Price, Profit, etc.)

    So, if you want to create an indicator, there should be no code that is specific to ProOrder or ProScreener.

    What you are showing is a system with specific code for ProOrder and in order to convert this system into an indicator you will have to remove all specific ProOrder code.

    Regards,

    Jaap

Viewing 4 posts - 1 through 4 (of 4 total)

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