Help programming this code to trade shorts as well
Forums › ProRealTime English forum › ProOrder support › Help programming this code to trade shorts as well
- This topic has 5 replies, 3 voices, and was last updated 6 years ago by Nicolas.
-
-
01/08/2018 at 4:28 PM #57766
Hi! I’m new to programming so need some help.
Why can’t I get this system to trade shorts as well?
Thxs, Magnus
1234567891011121314151617181920212223242526272829303132333435363738394041//-------------------------------------------------------------------------// Main code : Mov&RSI//-------------------------------------------------------------------------DEFPARAM CumulateOrders = falseShortRSI = RSI[3](close)LongRSI = RSI[25](close) //1 month RSIMA = Average[22,0](close) //1 month moving average of closeSlope = MA/MA[1]-1 //Slope of 1 month moving averageLongEntry = LongEntry AND ShortRSI < 15 //Buy when RSI2 below 15LongEntry = LongEntry AND LongRSI > 50 //Filter for long RSI above 50LongEntry = LongEntry AND Slope > 0 //Filter for positive slope of MovAvgLongExit = ShortRSI > 65 //Exit position when short RSI above 65// Conditions to enter long positionsIF LongEntry THENBUY AT MARKETENDIF// Conditions to exit long positionsIF LongExit THENSELL AT MARKETENDIFShortEntry = ShortEntry AND ShortRSI > 85 //Sell when RSI2 above 85ShortEntry = ShortEntry AND LongRSI < 50 //Filter for long RSI under 50ShortEntry = ShortEntry AND Slope < 0 //Filter for negative slope of MovAvgShortExit = ShortRSI < 35 //Exit position when short RSI under 35// Conditions to enter short positionsIF ShortEntry THENSELL AT MARKETENDIF// Conditions to exit short positionsIF ShortExit THENBUY AT MARKETENDIF01/08/2018 at 4:45 PM #57772Rules of the forum are written in bold and in the yellow box just above the text editor when you write a post, please respect them. Thank you.
At line 35 of your code, you must use SELLSHORT to initiate a new sell order, SELL instruction is made to close long orders.
Same for line 40, use EXITSHORT to close a short position.
01/09/2018 at 7:06 AM #5783801/09/2018 at 7:47 AM #5784001/09/2018 at 9:24 AM #57855I played about with it after I got no trades (even after Nicolas change) then I got it to trade but was a ‘oblique path to doom’ (looked like all losers?) then I reversed the buy sellshort conditions (as a quick look see) but still not good.
Then I started to change the code and got trades on Daily TF and 4 Hours, but was still looking way out so I abandoned it.
I reckon you should comment out all except 1 entry and 1 exit condition and get it trading and then uncomment more … making only 1 change at a time?
Please post results as I may get back into it at some stage?
GraHal
01/09/2018 at 10:00 AM #57858You can test each variable with the GRAPH instruction while backtesting, that way you’ll get a better view of what’s not working:
Just add these lines at the end of the code and launch a backtest.
12graph longentry as "long entry"graph shortentry as "short entry"If a variable is true, then it should be equal to 1, and a new order should be initiated as per your conditions.
-
AuthorPosts
Find exclusive trading pro-tools on