More ways to execute a study is now posted.

Questions about MultiCharts and user contributed studies.
bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

More ways to execute a study is now posted.

Postby bowlesj3 » 15 Jun 2011

There have been several people ask for this feature so some may want to vote for this. I put it out there at this link.

https://www.multicharts.com/pm/viewissu ... _no=MC-423

And maybe someone can tell me how to get rid of those <span> statements which always appear when I copy stuff in from a forum post. I clean all the stuff out but those keep coming back.

Thanks,
John.

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: More ways to execute a study is now posted.

Postby Stan Bokov » 15 Jun 2011

That <span> stuff is caused by the underlying software of the PM. For now, you can get rid of it by first pasting your text into Notepad (so that it becomes plain text) and then into PM.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Re: More ways to execute a study is now posted.

Postby SUPER » 15 Jun 2011

Stan,

Please can you advice how to use "RecalcLastBarAfter" in a script.

Regards
Super

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: More ways to execute a study is now posted.

Postby Stan Bokov » 15 Jun 2011

More info here - viewtopic.php?f=1&t=8414&p=39293&hilit= ... ter#p39227

Just use the keyword like this - RecalcLastBarAfter(.5) - this will recalculate the script after half a second.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: More ways to execute a study is now posted.

Postby bowlesj3 » 15 Jun 2011

That <span> stuff is caused by the underlying software of the PM. For now, you can get rid of it by first pasting your text into Notepad (so that it becomes plain text) and then into PM.
Thanks Stan,

I am going to do that to fix it up now. Also I have some ideas that just came to mind regarding the Function key execution of studies that I will put in that link. I figured I should mention it just in case you have already read it.

Note: There just be a cutoff for editing the post which I missed. therefore I put the comments about the F# key in an attached comment.

John.

User avatar
Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Re: More ways to execute a study is now posted.

Postby Stan Bokov » 15 Jun 2011

OK, thanks John.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Re: More ways to execute a study is now posted.

Postby janus » 15 Jun 2011

Thanks bowlesj3 for doing this on our behalf. I consider this an essential feature, and added my vote. Having said that the recent introduction of RecalcLastBarAfter may be all that is required, provided another enhancement is done (which I will come to below) at least for those who have extensive programming experience like myself. I haven't tested it yet but I can see how I can use RecalcLastBarAfter to force the study to "run itself" every second, and even if there was no tick update it will execute my own DLL, which can do any number of things, including checking the status of my existing external applications for any user input (eg, buttons pressed on a Windows app I've written a long time to perform various actions).

So, my question is how does a study distinguish between the two situations, one when the study runs due to an update tick, and the other when it's not and it was the result of RecalcLastBarAfter forcing the study to run? Is it the barstatus value? If so, what value is barstatus set for when RecalcLastBarAfter triggers the study to run?

The only other issue I see is when a study is triggered by the RecalcLastBarAfter feature and say a "sell at market next bar on close", it still isn't submitted until the next tick update, which can be several minutes away in a quiet market. If this is so then it reduces the value of RecalcLastBarAfter significantly, almost to the point of being useless for signals. This is one reason I've already submitted a feature request in PM to force an order to be submitted at the current close instead of the next close, so that we can use "sell at market this bar on close". So, that enhancement and in combination with RecalcLastBarAfter and with IOG turned on a signal study can work as expected, and MC would become an even more powerful tool than it already is for serious traders. If you feel this is important enough then please vote for my feature request titled make "this bar on close" work in real-time posted here: https://www.multicharts.com/pm/viewissu ... _no=MC-391

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: More ways to execute a study is now posted.

Postby bowlesj3 » 16 Jun 2011

Hi Janus,

The Barstatus question is interesting. I suspect that it is only applicable when the study is executed as a result of a tick and thus we really do need to know what caused the execution.

My feature request originated from a discussion of someone wanting to execute the study when the bid/ask changed even if there was no tick coming in. It was at that point I first started thinking about it. I can see why many traders would want their code executed when the bid/ask shifted up or down. I could even see them wanting code executed if the size of the bid/ask volume changed a large amount. In my case I want it because I use the (MC_TL_GetActive, MC_Text_GetActive,MC_Arw_GetActive) commands to control things. I do use bid/ask to control my limit so in time I may want code executed if the bid/ask changed. I suspect the new command RecalcLastBarAfter came as a result of someone wanting to cancel an order if the market got too thin. However having a regular timer function would be easier if one wants to get an average on this.


I think it is very important for TSS to keep in mind that if the user can execute the study more than one way (in other words there are several items sitting next to the "execute on every tick" check box and the program allows the user to check more than one item) then they need to have a way to tell the study that one method of execution has not completed yet and a lower priority of execution such as timer execution should be bypassed (this becomes even more important if 2 or more have been selected). So even with the RecalcLastBarAfter command I could set on a switch in a GV to tell me I called it, how do I know that a tick has not come in before it or even worse a tick has called the study again before the timer execution is completed. I guess I could assume the next execution is from the RecalcLastBarAfter command and change the GV to a value 2 at the top indicating the timer execution was under way and change it back to zero indicating the timer execution is complete. Thus if an execution came in and the GV value was already a 2 at the top them I could assume it was a tick execution. However this idea is not a reliable idea. It is better that MC set a memory area and have a reserve word than can get this value.

I am thinking that a memory field is needed for each type of execution and it should be loaded with the date/time of completion of that method. Therefore it could contain

value 0 not executing
negative date/time value which is the time it started executing.
Postiive date/time value which is the time it ended executing.

Therefore at the top of the study I may have code like this.

Code: Select all

If ExecutingOnTimer < 0 and ExecutingOnTick < 0 and ExecutingOnTimer < ExecutingOnTick then
exitStudy;
{ExecutingOnTimer < 0 tells us timer execution is in process}
{ExecutingOnTick < 0 tells us tick execution is in process}
{ExecutingOnTimer < ExecutingOnTick tells us the tick execution started first}
(Exit because We do not need to execute on timer because a tick is currently processing)
(Another reason to bypass is some users may be using the same variables on each type of execute)
To test a thin market we would use this (too lazy to get the exact code).

Code: Select all

If ExecutingOnTick > 0 and CurrentTime > ExecutingOnTick + WhateverMinutes/Seconds then
{Cancel my order because the market is too thin}
{Or build a thinness table for a later decision to cancel my order}
{ExecutingOnTick > 0 tells us tick execution finished and at what time it was finished}
Note: I created a link back to this discussion since the above idea makes a lot of sense. I had not thought these ideas out when I first got this general idea.

In the end I suspect that this general idea of "having studies executed more than one way" will evolve over time into a final perfected form that keeps everyone happy.

John

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Re: More ways to execute a study is now posted.

Postby janus » 16 Jun 2011

Hi bowlesj3.

I'm not sure if you have noticed but barstatus = -1 when a study is executed beacuse of another instrument running alongside the main chart. I use this to skip past my code since there is no real new information other than to let me know the other instrument received an update. I used to do this to increase the frequency of a study but now that we have RecalcLastBarAfter, I can dispense with that trick, although it's not quiet the same. However, as I explained before this is still not sufficient for a true real-time and dynamic trading system.

As for executing a study in a variety of ways, I say the more the better. It provides options for those who need them. My needs are simple yet I think of huge benefit by high frequency traders. I'm talking about the ability to submit a standard order immediately, whether there's an update tick from bid, ask, trade, or no update tick at all (using RecalcLastBarAfter). I know there are new commands that bypass the order management system that I think can be used to submit an order immediately, but they bypass the built-in order management system and requires a major re-write of a study to accommodate both types of orders. These new commands are only designed for emergencies to re-synch the position according to the broker and the study.

So, your suggestions should be implemented but with the major proviso than mine is also implemented, otherwise we will always be restricted to trading at least one tick behind the real world. For most traders this is not a problem but I know from experience and with other high frequency traders it sometimes is. My simple suggestion to make "this bar on close" work in real-time I believe is essential to provide a true real-time and dynamic trading system.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: More ways to execute a study is now posted.

Postby bowlesj3 » 16 Jun 2011

Hi Janus,

Actually I never knew that barStatus = -1 had any meaning.

What you wish for all sounds good to me. However I can't really vote for it because I know very little about it as the paragraph below may explain. I love MC but extract only what I need.

I enter all my orders from my database program preferring to analyse the market waves on the higher levels using manually determined arrow drops. I do this because I have found (and studies seem to back me up) that computers on average can not analyse patterns near as well as humans at this point. At the very least I figure for me to get EL code to do it as well as I can manually would take me a few life times. MC feeds the data to my database program via GVs that constantly analyses it using a timer. The program even reminds me when to mark the top or bottom of the wave since most of the time there are relationships between parent and child wave levels and I have built the rules for this into the timer process (at times I override the suggestion since I rejected having it try and figure out wall boundaries controlling the waves). I suspect many people do not realize that a trend is nothing more than the child wave level the trader is trading moving in the same direction as its parent wave level's implied projection (increasing the odds) and a child wave level shift controls the parent's implied top and bottom and its projection. This gets complex at times and if it takes me a while to figure out new ones controlled by a new unexpected bounce how am I going to have any hope of programming it and trusting it. Anyway, normally I let my code tell me when to arm auto trigger. If I decide to go ahead I actually block out the price action so I can not see what the auto trigger is doing so I do not risk emotions screwing it up (at that point the computer code is far better than I am). Also in the end if I see a situation that I know would be triggered by auto trigger I will simply press the button or maybe skip the lower level arrow drops and just set the auto trigger manually. This creates the ultimate in flexibility for me yet uses the computer extensively. I basically never touch traders work station unless my program aborts or something mid stream. So I have very little knowledge of how MC submits orders and I probably never will. I have no interest in it (yet at least). All my orders are submitted from the database program. .

John
Last edited by bowlesj3 on 16 Jun 2011, edited 3 times in total.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Re: More ways to execute a study is now posted.

Postby janus » 16 Jun 2011

By the sounds of it bowlesj3 you don't need to trade in high frequency mode. Most traders are like that. I have two broad approaches to trading. One is longer term like yours so the orders can be placed manually if need be, but I use my own DT plugin to ready the orders, and hit either the confirm or block button to control it. I do a lot more than this through my own plugin. Basically there are over 20 built-in actions I can take, and I can add more at any time very easily. My favourite one is the combination of a dynamic trailing stop and sloping stop limit line to scale out of my positions using several profit targets. The other general approach is more akin to scalping. This one definitely needs to have immediate action taken. Even a single tick delay can cost me too much in a rapidly moving market. I use my own queue depth analysis tools to warn of an impending opportunity, then I jump on it if I see the opportunity come up. In theory it's more profitable but in practice due to the limitation of MC I can't use it except when the market is of average volatility. I could use a couple of other platforms that do offer true real-time order processing but for now I'm happy to focus on the first approach. I will probably use another platform eventually for the higher frequency trades only.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: More ways to execute a study is now posted.

Postby bowlesj3 » 16 Jun 2011

I often remember the author of "Trading Systems and Methods" Perry J. Kaufman saying "There must be 1000 strategies". If that is true then I have to assume that most develop their strategies based upon the patterns they happen to stumble upon which seem reliable. So it appears that there is a lot all of us have not stumbled upon and never will nor do we have time for it all. Yes, if I do not see an implied $50 profit per contract (better $100) I don't bother risking it. That may cause me to not stumble upon all sorts of reliable patterns. Someone else said "find something that works and stick with it (my strategy is mostly go with the trend as described above)". This one restricts my searching for new reliable patterns as well.


Return to “MultiCharts”