Auto Trading Entry/Exit

Viewing 7 posts - 1 through 7 (of 7 total)
  • #173971

    Hello,

    So I tried my first Trading System on Demo, its on a 2min chart, it opens an Entry and then at the same time exit.

    I’m sure its not a fault with the software, its me.

    #173972

    Great you could find out how to make it work!

    Is there anything you missed to ask?

     

    1 user thanked author for this post.
    #173976

    it opens an Entry and then at the same time exit.

    Just show us your code and we probably will be able to see why it Exits right away.
    You best insert your code by means of the “Add PRT Code” button, but on my screen that button has disappeared.


    @Roberto
    , it should be there, see attachment. So I am probably blind today.

    #173978

    PS: And after posting my message, the button is suddenly back ? (see attachment).
    Apologies I did not make a screenshot of the “Visual” tab when it was missing.

    #173981

    There’s a bug that Nicolas is investigating.

    It often appears again by refreshing the page.

    In the meantime you can use the TEXT tab, which works.

     

    1 user thanked author for this post.
    #174053

    Hi there, this is the code

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the “FLATBEFORE” time.
    DEFPARAM FLATBEFORE = 080000
    // Cancel all pending orders and close all positions at the “FLATAFTER” time
    DEFPARAM FLATAFTER = 235500

    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 080000
    timeEnterBefore = time >= noEntryBeforeTime

    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 163000
    timeEnterAfter = time < noEntryAfterTime

    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0

    // Conditions to enter long positions
    indicator1 = Average[11](close)
    indicator2 = Average[47](close)
    c1 = (indicator1 CROSSES OVER indicator2)

    IF c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 1000 PERPOINT AT MARKET
    ENDIF

    // Conditions to exit long positions
    indicator3 = Average[47](close)
    indicator4 = Average[11](close)
    c2 = (indicator3 CROSSES OVER indicator4)

    IF c2 THEN
    SELL AT MARKET
    ENDIF

    // Conditions to enter short positions
    indicator5 = Average[47](close)
    indicator6 = Average[11](close)
    c3 = (indicator5 CROSSES OVER indicator6)

    IF c3 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    SELLSHORT 1000 PERPOINT AT MARKET
    ENDIF

    // Conditions to exit short positions
    indicator7 = Average[11](close)
    indicator8 = Average[47](close)
    c4 = (indicator7 CROSSES OVER indicator8)

    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF

    // Stops and targets
    SET STOP pLOSS 35
    SET TARGET pPROFIT 179

    #174054

     

    I did not try to follow your conditions really, in order to see that both conditions can be True and thus the first thing what may happen is the BUY and the subsequent next may be the SELL (this will probably happen in the next bar (call of the program) or else both cancel each other anyway).

    What lacks is lines like

    It is not per se so that a Sell without being OnMarket will imply a Short in code, though under conditions this may happen (like my “cancel out each other” example). It is merely about the logic you need to apply because else you will Buy (or Exit) two times.

    Good luck now !

    1 user thanked author for this post.
Viewing 7 posts - 1 through 7 (of 7 total)

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