Kasper Posted February 18, 2023 Report Share Posted February 18, 2023 Can you share an example external file and how it used within a scan? What type of code or languages are compatible? Including External Code #include This allows you to include code from an external file (specified following the #include). Example: #include c:\temp\mylibrary.code Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted February 19, 2023 Report Share Posted February 19, 2023 Basically, any snippet of the C# code that would work in advanced paintbar could be isolated into a separate file and included via the #include. The #include is there so that you can have a library of functions you use and #include it in paintbars without repeatedly inserting the same code in every paintbar where it would be used. Quote Link to comment Share on other sites More sharing options...
Kasper Posted February 21, 2023 Author Report Share Posted February 21, 2023 (edited) Hello Mike, thanks for this info, I'll try it out. I assume if there are any variables in external script requiring access to data will have to be added to internal paintbar code? The other question I have is about scan chart parameters such as frequency can be read from within a scan? I want to append this to naming SetInterVar() then call by GetInterVar() elsewhere based on frequency selected. Edited February 21, 2023 by Kasper Quote Link to comment Share on other sites More sharing options...
Kasper Posted February 21, 2023 Author Report Share Posted February 21, 2023 If it's not possible or too complicated then no worries. I am able to use DefinedPaintbarParameter and enter frequency identifier manually for each scan window. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted February 21, 2023 Report Share Posted February 21, 2023 #include just physically places that block of text from that file into the paintbar. Frequency - that's the CandleSizeInSec variable. Use that for the "freq". Quote Link to comment Share on other sites More sharing options...
Kasper Posted February 21, 2023 Author Report Share Posted February 21, 2023 (edited) Thank you, CandleSizeInSec works good for intraday. But on historical it returns following: 1Day=60 1week=300 so on.. Not sure if this is expected. Edited February 21, 2023 by Kasper Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted February 21, 2023 Report Share Posted February 21, 2023 Well. As long as it's consistent, it's good for your purposes... 1 Quote Link to comment Share on other sites More sharing options...
Kasper Posted March 3, 2023 Author Report Share Posted March 3, 2023 Is there a safe way to ready/write into to text (non-code csv) file from scans? Error: 24, 19 CS0103 Possible security violation Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted March 6, 2023 Report Share Posted March 6, 2023 The "Possible security violation" is there for a reason. We don't want paintbars/scans to write to files. Basically because if someone gave you a scan and you ran it and you didn't go through the code with a comb, it could do malicious stuff to your computer... Quote Link to comment Share on other sites More sharing options...
Kasper Posted March 17, 2023 Author Report Share Posted March 17, 2023 Hello Mike, I am now using Set/GetInterVar between MT and my WS-API app to exchange data. Can you tell me if it should work like data subscription? Within MT GetIntervar can stream between two scans. Do I need to do something on app for something similar? Also, is there a way to throttle a scan, say one scan pass over all symbols then wait n seconds before going again. Or if frequency on portfolio is set to 5 minutes thena rule to run scan every (frequency * 0.25) minutes. Thank you. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted March 17, 2023 Report Share Posted March 17, 2023 1. No, intervars don't stream. You have to get it every time you want an updated value. It is very light in terms of processing, so poll it as much as you want. Make sure you figure out what intervar you want - a symbol-specific one or a "global" one. 2. No need to throttle scans. You run the scan, it initializes (possibly slowly if there are a lot of backfills) then just runs on every update. Again, unless it is written really inefficiently (like huge loops for each run) it is pretty light, so no need to just run it every X minutes. But - if you really would like to, there is code that you can put in the scan that will only run once the candle is finished. Just check the IsNewCandle variable, and if true, run the calculations on the previous candle (which at that point would be finished). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.