Auto Trading Entry/Exit
Forums › ProRealTime English forum › ProRealTime platform support › Auto Trading Entry/Exit
- This topic has 6 replies, 3 voices, and was last updated 3 years ago by PeterSt.
-
-
07/21/2021 at 10:30 PM #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.
07/21/2021 at 10:52 PM #173972Great you could find out how to make it work!
Is there anything you missed to ask?
1 user thanked author for this post.
07/22/2021 at 8:02 AM #173976it 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.07/22/2021 at 8:03 AM #17397807/22/2021 at 8:44 AM #173981There’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.
07/23/2021 at 12:19 PM #174053Hi 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 17907/23/2021 at 1:31 PM #174054123456789101112IF c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENBUY 1000 PERPOINT AT MARKETENDIF// Conditions to exit long positionsindicator3 = Average[47](close)indicator4 = Average[11](close)c2 = (indicator3 CROSSES OVER indicator4)IF c2 THENSELL AT MARKETENDIFI 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
123456789101112131415If not OnMarket then// Do your Buy or Sell thing.Endif// or :If not LongOnMarket then// Do your Buy thing.Endif// or :If ShortOnMarket then// Do your Exit Short thing.EndifIt 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.
-
AuthorPosts
Find exclusive trading pro-tools on