For Statements
Forums › ProRealTime English forum › ProOrder support › For Statements
- This topic has 7 replies, 2 voices, and was last updated 7 years ago by Wing.
-
-
03/02/2017 at 2:03 AM #26868
Can you use for statements for automated trading, where each indicator refers to the last bars value?
Just a random example:
12345678910111213141516171819202122once x=0ax = x/3*abs(x-5)x=x+1if barindex>100 thena=0b=0c=0for i=1 to 100a=a+ax[barindex-i+1]b=b+ax[barindex-i+1]*ic=c+ax[barindex-i+1]*i*inextendifindictor = a*b/cif close crosses under indicatorbuy n contracts at marketendifDoesn’t seem to work for me.. Is it allowed?
03/02/2017 at 3:47 AM #2686903/02/2017 at 3:48 AM #2687003/02/2017 at 3:54 AM #2687103/02/2017 at 3:56 AM #2687203/02/2017 at 4:29 AM #2687303/02/2017 at 4:32 AM #2687403/02/2017 at 5:03 AM #26875Do you define all your variables from the start, and have you tried for example defparam preloadbars=1000? Also, isn’t the value of ‘indicator’ much greater than the close price? I don’t think there is anything wrong with your method or the for statements here, but rather the example you have. Here is for example an indicator I have made that uses for statements to gather data from previous bars: https://www.prorealcode.com/topic/pattern-matching-price-movements-in-prt/
-
AuthorPosts
Find exclusive trading pro-tools on