Newbee PSAR Code

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #174600 quote
    NEWBEE2020NEWBEE2020
    Participant
    Junior

    Hello,

    I’m quite new at this forum, been playing around with Prorealtime for a year now.

    Here is some code which is profitable, but sadly also returns a “divide by zero error” (I already have the fix but does not work…)

    //-------------------------------------------------------------------------
    // Hoofd code : PSAR
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    // Hoofd code : sar
    //-------------------------------------------------------------------------
    // Hoofd code : OBV KOERS
    //-------------------------------------------------------------------------
    // Definitie van code parameters
    DEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd
    
    //dive by zero fix
    Gap = Close-CustomClose[1]
    IF Gap = 0 THEN
    Gap = 0.000001
    ENDIF
    
    // Condities om long posities te openen
    indicator1 = SAR[0.02,0.02,0.2]
    c1 = (indicator1 CROSSES UNDER close)
    
    BUDGET = ((10000 + STRATEGYPROFIT) *5)/CLOSE
    AANTAL = ROUND(BUDGET)
    
    IF c1 THEN
    BUY AANTAL CONTRACT AT MARKET
    AANKOOP = CLOSE
    ENDIF
    
    IF CLOSE < (0.99*AANKOOP) THEN
    SET STOP pTRAILING 1
    ENDIF
    
    IF CLOSE > (1.01*AANKOOP) THEN
    SET STOP pTRAILING 1
    ENDIF

     

    Please let me know if you have an idea

    Enjoy the code

    Kind regards,

    Reinier

    sar-162799021048plc.jpg sar-162799021048plc.jpg sar-162799021048plc1.jpg sar-162799021048plc1.jpg
    #174844 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    To get a “division by 0” it needs a division, which I can’t spot.

    In any case you have to check all divisions.

    That fix can yield very incorrect results. Multiply or divide CLOSE by that number and you will see the result!

Viewing 2 posts - 1 through 2 (of 2 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

Newbee PSAR Code


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
NEWBEE2020 @newbee2020 Participant
Summary

This topic contains 1 reply,
has 1 voice, and was last updated by robertogozzirobertogozzi
5 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/06/2021
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...