Automatic trading not working?
Forums › ProRealTime English forum › ProOrder support › Automatic trading not working?
- This topic has 11 replies, 4 voices, and was last updated 5 years ago by Vonasi.
-
-
08/14/2018 at 11:25 PM #78209
So I’ve made a beginner system, but that’s not important I’ve set it up for when stochastic goes below 75 it should sell and when above 25 it should buy. why the hell is it not doing anything?
I placed some red lines where I belive it should’ve taken action but it didn’t…
any suggestions welcome thanks!
08/15/2018 at 12:19 AM #78211We need code to tell what’s going wrong.
1 user thanked author for this post.
08/15/2018 at 5:00 PM #78292Hi Robert, good idea. Thank you for your reply.
<
1 HOUR CHART, 100/200 SMA, STOCHASTIC 14,3,312345678910111213141516171819202122232425262728293031//-------------------------------------------------------------------------// Main code : 1 Hour 100/200 SMA STO 14,3,3//-------------------------------------------------------------------------// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = Average[100](close)indicator2 = Average[200](close)c1 = (indicator1 CROSSES OVER indicator2)indicator3 = Stochastic[14,3](close)c2 = (indicator3 > 25)IF c1 AND c2 THENBUY 1 PERPOINT AT MARKETENDIF// Conditions to enter short positionsindicator4 = Average[100](close)indicator5 = Average[200](close)c3 = (indicator4 CROSSES UNDER indicator5)indicator6 = Stochastic[14,3](close)c4 = (indicator6 < 75)IF c3 AND c4 THENSELLSHORT 1 PERPOINT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 150SET TARGET pPROFIT 30008/15/2018 at 5:11 PM #78297It is difficult to tell from your image as I can’t tell which lines are which averages but your code expects the cross and the level of stochastic conditions to be met on the same bar whereas from your image it appears that you are expecting the cross to happen and then a trade to be entered when the stochastic level is crossed a few bars later. Am I right?
1 user thanked author for this post.
08/15/2018 at 5:49 PM #78301Yes that’s correct, thank you for your reply. Id like the stochastic to work after the cross happens on the SMA. How would you go about fixing this? I’m very much a beginner…
08/15/2018 at 6:38 PM #78312You would need to set a flag when each event happens and then only enter when both flags are true. Something like this might work but I’ve not tested it:
123456789101112131415161718192021222324252627282930313233DEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = Average[100](close)indicator2 = Average[200](close)indicator3 = Stochastic[14,3](close)if indicator1 CROSSES OVER indicator2 thencross = 1endifif indicator3 crosses over 25 thenstochlevel = 1overif indicator1 CROSSES UNDER indicator2 thencross = -1endifif indicator3 crosses under 75 thenstochlevel = -1IF cross = 1 AND stochlevel = 1 THENBUY 1 PERPOINT AT MARKETENDIFIF cross = -1 and stochlevel = =1 THENSELLSHORT 1 PERPOINT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 150SET TARGET pPROFIT 3001 user thanked author for this post.
08/16/2018 at 11:34 PM #78425Thanks for your reply Vonasi.
I’ve not come across this problem before, it says I have a syntax error on line 34 yet I don’t have a line 34? how on earth do I fix that?
Assistance much appreciated.
08/17/2018 at 4:10 AM #78428Line 12 and line 20 are both missing a matching ENDIF, so at the end of the code an error message is output.
1 user thanked author for this post.
08/17/2018 at 8:40 AM #78433..also line 27 has an extra = instead of a – sign..
More haste, less speed, Vonasi!
1 user thanked author for this post.
08/17/2018 at 1:08 PM #78461More haste, less speed, Vonasi!
Looking at the time that I posted it is probably more haste, less beer!
I think we should all leave a line or two out of our code when providing it for others and see if they can work it out on their own. Nothing in life should come too easy!
1 user thanked author for this post.
08/17/2018 at 5:00 PM #78482Of course the endifs where missing! I managed to correct line 27 myself but am still learning. Thanks for your help!
08/17/2018 at 5:34 PM #7848812345678910111213141516171819202122232425262728293031323334DEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = Average[100](close)indicator2 = Average[200](close)indicator3 = Stochastic[14,3](close)if indicator1 CROSSES OVER indicator2 thencross = 1endifif indicator3 crosses over 25 thenstochlevel = 1endifif indicator1 CROSSES UNDER indicator2 thencross = -1endifif indicator3 crosses under 75 thenstochlevel = -1endifIF cross = 1 AND stochlevel = 1 THENBUY 1 PERPOINT AT MARKETENDIFIF cross = -1 and stochlevel = -1 THENSELLSHORT 1 PERPOINT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 150SET TARGET pPROFIT 300Just to redeem myself the above is the corrected code – I still have no idea if it works or is what you want but at least this one was done after only one beer! 🙂
-
AuthorPosts
Find exclusive trading pro-tools on