Strange if condition code error
Forums › ProRealTime English forum › ProOrder support › Strange if condition code error
- This topic has 26 replies, 5 voices, and was last updated 7 years ago by
Vonasi.
-
-
06/22/2018 at 4:33 PM #74105
Actually that proves that there is a problem.
When Long 1 is activated the tradecount is/was 0 and after the buy became tradecount 1, but since we used “not onmarket”, the others shouldn’t be activated until Long 1 are closed.
Your solution is a nice workaround to the problem. 🙂
The other solution was nice too, though it worked the way I solved it too. Nice with more ways. 🙂
06/22/2018 at 5:30 PM #74108Here, I created a simple batchfile for Windows you can test how easy it should be done. Copy the text to a textfile and save the file to something.bat (example tradetest.bat) and run the batchfile. 🙂
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172@echo offset tradecount=0:0clsECHO.ECHO Test of IF-statementECHO.ECHO Start with tradecount 0.ECHO Trade 1 need tradecount 0 to be set.ECHO Trade 2 need tradecount 1 to be set.ECHO Trade 3 need tradecount 2 to be set.ECHO.ECHO Trade 1 while accepted sets tradecount to 1.ECHO Trade 2 while accepted sets tradecount to 2.ECHO Trade 3 while accepted sets tradecount to 3.ECHO.ECHO.ECHO 1. Enter Trade 1ECHO 2. Enter Trade 2ECHO 3. Enter Trade 3ECHO 4. Reset Tradecount to 0ECHO 5. ExitECHO.set /p userinp=Enter alternative 1-5:if "%userinp%"=="1" goto :1if "%userinp%"=="2" goto :2if "%userinp%"=="3" goto :3if "%userinp%"=="4" goto :4if "%userinp%"=="5" goto :5clsgoto 0:1if "%tradecount%"=="0" (ECHO Trade enteredset tradecount=1) else (Echo No trade.)pausegoto 0:2if "%tradecount%"=="1" (ECHO Trade enteredset tradecount=2) else (Echo No trade.)pausegoto 0:3if "%tradecount%"=="2" (ECHO Trade enteredset tradecount=3) else (Echo No trade.)pausegoto 0:4set tradecount=0goto 0:5exit06/22/2018 at 6:29 PM #74115Actually that proves that there is a problem.
No it proves there is not a problem. You are not on the market – the code is read from top to bottom at the close of a candle. Long1 criteria is read and all conditions met and tradecount is set at 1. Then Long2 is read and all conditions are met because Long1 just changed them so Long2 then sets tradecount to 2. Then Long3 is read and Long2 just set all the conditions for it so tradecount is set to 3. At no point up to now has anything been bought as that order does not go to the market until the last line of code has been read.
06/22/2018 at 7:06 PM #74123Actually that proves that there is a problem.
No it proves there is not a problem. You are not on the market – the code is read from top to bottom at the close of a candle. Long1 criteria is read and all conditions met and tradecount is set at 1. Then Long2 is read and all conditions are met because Long1 just changed them so Long2 then sets tradecount to 2. Then Long3 is read and Long2 just set all the conditions for it so tradecount is set to 3. At no point up to now has anything been bought as that order does not go to the market until the last line of code has been read.
You are wrong speaking about pretty much every other programming language in the world. If it goes from top to bottom and not everything is done at the same moment (as it could do with the future quantum computing as an example), it should go from top to bottom doing one if statement at a time (not all at a time), if not – this is the bug in PRT’s compiler. It should be like this:
Checking Long 1
Long 1 accepted
buys contract
adds the tradecount value by one
closes the statementMoves to the next statement,
checking Long 2
since contract was bought in previous statement we are “on market”
Long 2 not accepted and closed.Same thing for Long 3.
Now check the easy batch file for Windows I created in my previous post and test it, even that easy language which also moves from top to bottom works as intended. Please reply after testing the batch file. I don’t have time to prove the concept in VB, c, c++, c#, php, python and so on, most (or all) languages work this way except this problem within PRT.
06/22/2018 at 8:32 PM #74129I’m not interested in the batch file as it is not PRT code and so completely irrelevent.
We are not talking about any other programming language. We are talking about PRT code and how it works. How I described and how I finally wrote it is how PRT expects it to be written to work and the confirmation is that it works.
Maybe you should look at some of the coding courses on this website or read the PRT documentation also available on here so as to fully understand how PRT code is expected to be written.
I would suggest completely forgetting how other languages expect it to be and what works in other languages and code it how PRT expects it to be otherwise you will make life very hard for yourself. It is not a bug it is just a different logic! 🙂
06/22/2018 at 8:38 PM #74130Checking Long 1
Long 1 accepted
buys contract NO IT DOES NOT BUY THE CONTRACT
adds the tradecount value by one YES IT DOES ADD ONE TO TRADECOUNT
closes the statement
Moves to the next statement,
checking Long 2 since contract was bought in previous statement we are “on market” NO WE ARE NOT IT DID NOT BUY AS IT BUYS AT THE END OF READING EVERYTHING
Long 2 not accepted and closed. YES IT IS AS TRADECOUNT IS 1 AND WE HAVE BOUGHT NOTHING YET AS WE BUY ONCE EVERYTHING IS READ. TRADECOUNT IS NOW MADE TO BE 2 SO LONG 3 WILL DO THE SAME AS WE ARE STILL NOT ON MARKET
Same thing for Long 3.
06/23/2018 at 12:23 AM #74143I’m not interested in the batch file as it is not PRT code and so completely irrelevent.
We are not talking about any other programming language. We are talking about PRT code and how it works. How I described and how I finally wrote it is how PRT expects it to be written to work and the confirmation is that it works.
Maybe you should look at some of the coding courses on this website or read the PRT documentation also available on here so as to fully understand how PRT code is expected to be written.
I would suggest completely forgetting how other languages expect it to be and what works in other languages and code it how PRT expects it to be otherwise you will make life very hard for yourself. It is not a bug it is just a different logic!
Actually it’s not irrelevent because the language would be much better if it worked like all the other languages (if it where better the PRT way other languages would handle IF statements the same way, but it’s not a smart usage of IF).
About videos or documentation, can you point me in the direction where it’s described that IF workes in the way you describes it (I looked through the official pdf-manuals but couldn’t find anything about how PRT treats IF statement), I just want to see/read about it. About progamming in itself, I already know how to program.
And if you don’t know it, it’s really rude to scream in your posts (it’s when you write with caps), and it’s really unprofessional coming from a moderator.
06/23/2018 at 5:43 AM #74145It is nothing to do with the IF THEN statement it is is to do with the fact that orders are not placed on the market until the code is read all the way to the end and so you are not ONMARKET until that has happened . You will not be on market for an IF THEN until the close of the next candle. I have tried to make this clear in at least one previous post but you just kept saying it is a PRT problem which it was not. It was as we say in the engineering trade ‘a bad workman always blames his tools’. You are blaming PRT when in fact you are holding the wrong end of your hammer. At a certain point if someone keeps holding the hammer by the wrong end and keeps blaming the hammer then it becomes necessary to shout to get your point across – and I finally got the point across and you now understand where you were going wrong – so it was a worthwhile shout. 🙂
As for being a moderator I think you misunderstand what that means. Moderators are the same as other forum users and are free to have their own opinions and even shout if they feel it to be necessary to get a point across. The only difference between a moderator and any other forum member is that they have been noted for their regular forum participation and willingness to help others and so deemed trustworthy enough to be given a few tools to tidy up other peoples posts, move posts to the correct place and delete posts that are unsuitable or unnecessary.
06/23/2018 at 6:22 PM #74192Ok then I know why it works the way it works (even though you didn’t point me in the direction to some official documentation – maybe it’s not documented). About the caps post, I didn’t read it because I don’t tolerate yelling and disrespect. I felt like yelling too at some point but where bigger than that.
Either way, it would be good if it was possible to set some varaible that if a buy condition is met, no more statements should be read until the next candle (then you put anything you want to be done in each statement). Or the system could by default recognize that a buy order has been met and stop reading until the next candle. Well it is the way it is.
So for my sake this thread is retired, you have a nice day!
06/23/2018 at 7:08 PM #74198it would be good if it was possible to set some varaible that if a buy condition is met, no more statements should be read until the next candle (then you put anything you want to be done in each statement)
There is no reason why you cannot do this except for the fact that it is totally unnecessary as just putting the IF THEN statements in the right order provides the neatest solution to achieving what you require.
I provided three solutions for you, one to your first request which you then changed to something different and then a stop gap solution and then very soon after the correct code to do what you wanted. I didn’t need to provide you with anything but I am a helpful sort of chap who enjoys a challenge. The thread should have been retired at that point with a simple ‘thank you’ rather than you continuing on about it being a PRT problem or bug.
BUY’s and SELL’s and SELLSHORT’s and EXITSHORTS will all be done at the close of a candle and after the code has been read from top to bottom and never before. I have never seen anyone else complain about this little bit of logic that takes seconds to understand before you did. You see it once and then you write your code accordingly. I cannot imagine PRT will be interested in changing it when everyone coding with PRT is perfectly able to grasp and work with this simple logic. Plus if they changed it then all previously written codes would no longer work correctly.
p.s. you did read my code with the capital letters in it otherwise you would not have finally understood where you were going wrong. 🙂
Oh and threads are never retired – they live on forever…… oh and thanks for wishing me a nice day. I did have a nice day, I went for a swim and cleaned the bottom of the boat while I was in the crystal clear water and then I went for a sail round the island of Meganissi and I finished the day off with a curry and a nice glass of red wine or two. A jolly nice day it was. 🙂
06/23/2018 at 7:48 PM #74199I went for a sail round the island of Meganissi
Aha now I know where you are Vonasi, just checked you out on google maps.
I have wanted to ask (I’m a nosy chap) but thought you may think I would drop in on you! 🙂
Sounds like you did have a very very nice day!
06/23/2018 at 8:11 PM #74200Sounds like you did have a very very nice day!
The day was only ruined by having to do the washing up. It is one of the major problems of living on a boat – nowhere to put a dishwasher nor the water and electricity to supply it! But somehow we cope.
Drop in any time although I might have sailed somewhere else – if so look for me downwind!
Off topic now so I will have to tell my self off and ask myself to try to stick to the topic being discussed.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on