How to use ArraySort and unset?
Forums › ProRealTime English forum › ProOrder support › How to use ArraySort and unset?
- This topic has 7 replies, 4 voices, and was last updated 2 years ago by Nicolas.
-
-
01/22/2022 at 9:33 AM #186254
Hi,
I have an issue with “ArraySort($MAArray, ASCEND)” in Pro order.
The same with Unset, the way I code is not correct? Please advise.
e.g.
12345$MAArray[1] = DMAS20$MAArray[2] = DMAS50$MAArray[3] = DMAS200ArraySort($MAArray, ASCEND)br
CKW
01/22/2022 at 9:47 AM #186256Rewrite those few lines trying not to type unsupported characters.
If the error is still reported, then it’s an error in one of the lines prior to 248.01/22/2022 at 10:32 AM #186260@CKW, if that is in ProOrder indeed (hence Strategy Code and not an Indicator) … both ArraySort and Unset are not supported there. You can see that by the syntax highlighting. So do you ?
https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/page/12/#post-185587
01/22/2022 at 10:58 AM #186263Hi PeterSt, Robertogozzi,
Thanks.
@CKW, if that is in ProOrder indeed (hence Strategy Code and not an Indicator) … both ArraySort and Unset are not supported there. You can see that by the syntax highlighting. So do you ?
https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/page/12/#post-185587
Thanks for telling that Pro order not support both ArraySort and unset :). There is no warning /error description saying that this syntax are not supporting.
br
CKW
01/22/2022 at 11:37 AM #186268There is no warning /error description saying that this syntax are not supporting.
Hmm …
Paste this over the standard code in a new strategy :
1234567891011121314151617181920212223242526272829// Condities om long posities te openenUwcondities = 1IF NOT LongOnMarket AND UwCondities THENBUY 1 CONTRACTS AT MARKETENDIF// Condities om long posities te sluitenIf LongOnMarket AND UwCondities THENSELL AT MARKETENDIF// Condities om short posities te openenIF NOT ShortOnMarket AND UwCondities THENSELLSHORT 1 CONTRACTS AT MARKETENDIF// Condities om short posities te sluitenIF ShortOnMarket AND UwCondities THENEXITSHORT AT MARKETENDIF// Stops en targets : Voer uw beschermende stops en winst targets hier in$MAArray[1] = DMAS20$MAArray[2] = DMAS50$MAArray[3] = DMAS200ArraySort($MAArray, ASCEND)You should see that warning sign at the bottom line. If not, I wonder what could be going on.
But watch out. The below code (see attached) shows the lines pasted from your post. And now the syntax error does *not* show, BUT it appears on line 1 you see there (I copied the line numbers from the code you showed).This makes Roberto’s remark correct in the first place because now indeed the message appears as with you. Btw hint : this is most probably about an If/Endif mismatch.
But the ArraySort and Unset are still not supported … 🙁01/22/2022 at 11:40 AM #186270PS:$MAArray[1] = DMAS20
Not that you asked for it, but notice that the first element of an array is [0] (not [1]).
01/22/2022 at 12:09 PM #186276Not that you asked for it, but notice that the first element of an array is [0] (not [1]).
I actually almost always start from element 1 (I count elements myself, I only occasionally use LASTSET).
I prefer using element 0 to store say, the date I created it, or last modified it, or any other info I may need, sometimes assembling numbers to combine conditions, such as:
– first digit (1=only for LONG trades, 2=only for SHORT trades, 9=all trades allowed, not 0 because it would be dropped, being the first digit)
– second to seventh digit for the last time I modified/added any element
– and more, provided it does not exceed the supported length (which I don’t know, maybe 12+ digits)
– then 5 digits for the number of elements
so it may contain 9 09300 00212 (which is for ALL trades, LAST modified at 9:30am, containing 212 elements, combined is 909300000212).
1 user thanked author for this post.
01/24/2022 at 3:59 PM #186466 -
AuthorPosts