My short positions won’t close

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #186193 quote
    1548284715482847
    Member
    New

    Hi,

    Please forgive my ignorance as I’m a beginner to PRT coding.

    I have a very basic code that looks at 4H charts.

    -If the previous candle closes green then it enters a long.

    -If the previous candle closes red then it enters a short.

    I am trying to get it to close at the end of each candle, this seems to be working for my long positions but not my short.

    Any advice would be greatly appreciated on why my code is not working properly.

    Thank you in advance and happy trading!

    Anton

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    c1 = (close >= close[1])
    
    IF c1 THEN
    BUY 4 CONTRACT AT MARKET
    ENDIF
    
    SET STOP pLOSS 300
    
    // Conditions to exit long positions
    c2 = (close CROSSES OVER close)
    
    IF Longonmarket then
    IF open<close Then
    SELL AT MARKET
    ENDIF
    ENDIF
    
    // Conditions to enter short positions
    c3 = (close < close[1])
    
    IF c3 THEN
    SELLSHORT 4 CONTRACT AT MARKET
    ENDIF
    
    c4 = (close CROSSES OVER close)
    // Conditions to exit short positions
    IF Shortonmarket then
    IF open>close Then
    SELL AT MARKET
    ENDIF
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 300
    #186194 quote
    GraHalGraHal
    Participant
    Master

    Line 33 needs to be …

    
    ExitShort AT MARKET
    
    15482847 thanked this post
    #186207 quote
    1548284715482847
    Member
    New

    Thank you very much, I appreciate it!

    GraHal thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

From idea to ProBuilder code in seconds.

Your coding copilot for ProRealTime™. Ask in plain English — get clean, ready-to-paste indicators, screeners and systems.

Available in 7 languages
Try ProRealAI

My short positions won’t close


General Trading: Market Analysis & Manual Trading

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by 1548284715482847
4 years, 8 months ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 01/21/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...