New to PRT and PBC, so be firm and fair…

Forums ProRealTime English forum ProOrder support New to PRT and PBC, so be firm and fair…

Viewing 15 posts - 16 through 30 (of 45 total)
  • #246715

    Okey Dokey….
    So, code runs 👍

    and here come the questions….

    See attached image…
    1.It looks like I have two live trades, I think ?
    2.The orange and blue arrows – I cant find the legend to understand what they represent, or how to change the colours ?
    3.My code isn’t performing correctly, as aligning the range period with the test output (best period = chart period), my code is entering and exiting trades days after or days before !

    Any guidance, is very much appreciated during these very early days of PRT and the use of PBC (ProBuilderCode) 👍👍
    NT

    #246716

    No image attached in above post.

    1 user thanked author for this post.
    #246718

    One of those defrost moments 😕

    #246720

    It’s much easier to show positions as in attached.

    Click on your System / Algo title top left of equity curve > Configure > enable Positions Indicator.

    1 user thanked author for this post.
    #246723

    It’s much easier to show positions as in attached.

    Click on your System / Algo title top left of equity curve > Configure > enable Positions Indicator.

    Got that…
    But the positions graph for trade entry / exit, do not line up with the indicator and the crossover/under entry trigger (As coded)

    Also, how do I change the orange and blue colours, still not finding that one. <<< SOLVED 👍

    And what do the numbers mean 2 or 4 by the arrows?
    (It looks like I am entering two trades or even four trades at a time)

    #246725

    If you put the positions Indicator (as my screenshot) on your Chart you will see clearer.  I’m so used to seeing the Positions Indicator.
    Your colours don’t seem logical? It looks like you have closed a Long at a loss of 445 and then also opened a Short ?

    I take it this is on a Demo Account with virtual money … as you are testing code and getting used to the Platform etc?

     

    1 user thanked author for this post.
    #246727

    Yep. My coding is useless, it is opening a trade, and the closing it, at the same time… which is pointless….

    The code is supposed to do the following…

    Trade entry logic (as a test)
    ——————————–
    Long: DM+ cross over DM-

    Short: DM- cross over DM+

    Trade Exit Logic
    ——————–
    1. stop loss hit
    2. opposite signal triggered. Where the open trade is closed and the opposite signal trade is entered.

    Looking at the output, that isn’t the case 😱

    I could really do with code correction advice….

    #246728
    Attached shows where colours for trading icons are set

    This is your working code:

    Are you using the Roberto provided code? Also, are you incorporating Roberto suggestion re MyMACD etc.
    Roberto will help I’m sure. Asking 1 or 2  specific questions / problems at a time is best.

     

    1 user thanked author for this post.
    #246731
    Attached shows where colours for trading icons are set

    This is your working code:

    Are you using the Roberto provided code? Also, are you incorporating Roberto suggestion re MyMACD etc.

    Roberto will help I’m sure. Asking 1 or 2 specific questions / problems at a time is best.

    Got that… thank you…

    Yes, using Roberto’s code and the my* code handling, which is now amended… well, it is working better, but not resolved as per the entry and exit logic…

    Trade entry logic (as a test)
    ——————————–
    Long: DM+ cross over DM-

    Short: DM- cross over DM+

    Trade Exit Logic
    ——————–
    1. stop loss hit (OR)
    2. opposite signal triggered. Where the open trade is closed and the opposite signal trade is entered.

    Here is the revised code, any assistance to rectify the process is very much appreciated.

    // ========================================================================
    // STRATEGY: DMI-ADX Crossover with Stop Loss + Opposite Signal Exit + Delayed Re-entry
    // ========================================================================

    // === INPUTS ===
    DMIperiod = DMIPeriod // optimize from 1 to 20
    ATRperiod = 14
    ATRmultiplier = 2.5
    PositionSize = 10

    // === INDICATORS ===
    myDIplus = DIPLUS[DMIperiod]
    myDIminus = DIMINUS[DMIperiod]
    ATR = ATR[ATRperiod]

    // === SIGNALS ===
    LongSignal = myDIplus CROSSES OVER myDIminus
    ShortSignal = myDIminus CROSSES OVER myDIplus

    // === STOP LOSS DISTANCE ===
    StopLossDistance = ATR * ATRmultiplier

    // === STATE FLAGS ===
    reverseToLong = 0
    reverseToShort = 0

    // === POSITION MANAGEMENT ===
    IF LongOnMarket THEN
    // 1. Check stop loss
    IF low <= (tradeprice(1) – StopLossDistance) THEN
    SELL AT MARKET
    // 2. Check for reversal
    ELSIF ShortSignal THEN
    SELL AT MARKET
    reverseToShort = 1
    ENDIF
    ENDIF

    IF ShortOnMarket THEN
    // 1. Check stop loss
    IF high >= (tradeprice(1) + StopLossDistance) THEN
    EXITSHORT AT MARKET
    // 2. Check for reversal
    ELSIF LongSignal THEN
    EXITSHORT AT MARKET
    reverseToLong = 1
    ENDIF
    ENDIF

    // === ENTRY WHEN FLAT ===
    IF NOT LongOnMarket AND NOT ShortOnMarket THEN
    IF reverseToLong THEN
    BUY PositionSize SHARES AT MARKET
    reverseToLong = 0
    ELSIF reverseToShort THEN
    SELLSHORT PositionSize SHARES AT MARKET
    reverseToShort = 0
    ELSE
    IF LongSignal THEN
    BUY PositionSize SHARES AT MARKET
    ELSIF ShortSignal THEN
    SELLSHORT PositionSize SHARES AT MARKET
    ENDIF
    ENDIF
    ENDIF

    summary output…
    “Date” “Type” “Price” “Qty” “Value”
    “9 Jan 2020, 05:00:00” “Sell (entry)” “3,972.3” “-10” “39,723.00”
    “14 Jan 2020, 05:00:00” “Buy (exit)” “4,013.8” “10” “40,138.00”
    “26 Feb 2020, 05:00:00” “Sell (entry)” “4,241.9” “-10” “42,419.00”
    “18 Mar 2020, 04:00:00” “Buy (exit)” “4,053.6” “10” “40,536.00”
    “23 Mar 2020, 04:00:00” “Sell (entry)” “3,451.0” “-10” “34,510.00”
    “31 Mar 2020, 05:00:00” “Buy (exit)” “3,843.0” “10” “38,430.00”
    “2 Apr 2020, 05:00:00” “Sell (entry)” “3,522.3” “-10” “35,223.00”
    “7 Apr 2020, 05:00:00” “Buy (exit)” “3,839.0” “10” “38,390.00”
    “9 Apr 2020, 05:00:00” “Sell (entry)” “3,838.1” “-10” “38,381.00”
    “13 Apr 2020, 05:00:00” “Buy (exit)” “4,000.4” “10” “40,004.00”
    “16 Apr 2020, 05:00:00” “Sell (entry)” “3,635.8” “-10” “36,358.00”
    “21 May 2020, 05:00:00” “Buy (exit)” “3,359.1” “10” “33,591.00”
    “26 May 2020, 05:00:00” “Sell (entry)” “3,351.1” “-10” “33,511.00”
    “27 May 2020, 05:00:00” “Buy (exit)” “3,441.2” “10” “34,412.00”
    “12 Jun 2020, 05:00:00” “Sell (entry)” “3,283.2” “-10” “32,832.00”
    “6 Jul 2020, 05:00:00” “Buy (exit)” “3,204.3” “10” “32,043.00”

    #246750

    Try this one (I am also attaching the ITF file):

    2 users thanked author for this post.
    #246763

    open trade is closed and the opposite signal trade is entered.

    Try adding below at Line 39 in Roberto code posted above.

     

    2 users thanked author for this post.
    #246764

    Tip for Neo  / Anybody … if you pres Ctrl + F5 BEFORE starting to type then you will / should see the blue ‘Insert PRT Code’ as shown at red arrowhead in attached.

    Click the blue ‘Insert PRT Code’ when you are ready to enter code (use only for code) and then your code will appear formatted as shown in my post above … so much easier to read and understand as code.

    1 user thanked author for this post.
    #246770

    Try adding below at Line 39 in Roberto code posted above.

    I actually forgot to remove lines 39 and 40, as those two variables are no longer set and used.

    If you add those lines, though, the two variables will ALWAYS be true and the following instructions executed no matter what! So you have to clear them initially, then decide when they are to be set to TRUE. But, if I coded the TS correctly as planned, your suggested lines shouldn’t be needed.

     

    2 users thanked author for this post.
    #246780

    Try this one (I am also attaching the ITF file):

    Hi there Roberto.
    Sorry, I’ve been away the weekend…
    Thank you for the code update, just putting it through a test…

    I have amended this bit…
    DMIperiod = DMIperiod // 14 optimize from 1 to 20 [Which was // DMIperiod = 14 // optimize from 1 to 20]
    Amended as the optimisation wont run!

    NT

    #246781

    Just tested the file….
    The output is blank, not sure why.

    I’ll have a go at solving now…
    And any guidance you/anyone can give is much appreciated.

    NT

Viewing 15 posts - 16 through 30 (of 45 total)

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