Page 1 of 1

Base Logic for Interactive Text Script: Likely of use to all

Posted: 10 May 2010
by bowlesj3
NOTE: Regarding the next paragraph, as of MC 7.0 Beta 1 and later, new Getactive commands were created to replace the ones below which changed to acting like the TS GetActive commands upon MC 6.0 Beta 3. These new MC 7.0 commands are MC_TL_GetActive, MC_Text_GetActive and MC_Arw_GetActive.

Actually this thead has a few ideas and scripts that make use of the old MC version of the Arw_GetActive, Text_GetActive, TL_GetActive commands. Near the end there is a new one I added which is a practical value of the base script that is in this post (Something that could be useful for almost any trader so I donated it to promote the use of these old versions of these commands).


Written by John Bowles.

This is a Base Interactive Script/Study you can use for manually starting or stopping a study by clicking a text command on the chart

Its uses are only limited to things you can come up with - In theory its use is infinite.
It does not matter if you are a fully automated trader or not.
Most likely you can at some point find a use for the logic behind this script.
Just insert your logic where it says to do so in the script comments.

As an example, you might want it to clear old trend lines from your chart prior to a certain time or date. Insert that loop in this script and you just highlight the letter on the chart and it is done. Once it is complete you remove the highlight.

It will work on any MC version before MC 6.0 beta 3 and will work when they reestablish the MC version Text_GetActive logic.
The command will most likely be different when they bring the functionality back.

This base can be used for doing exactly the same thing with arrows or the trend line.
Maybe in time I will put samples in this thread.
Obviously you can do it with seconds bars commands as well.

Most likely you will want to remove the RingOut.wave sound if you create an actual application for this script.

One final note. I forgot to mention that (with arrows at least) this command can be very useful with arrow manual drops rather than arrows which are preplaced by a study. Generally this would be done with the higher numbered IDs on the chart after all the preassigned IDs are used by studies.

Posted: 10 May 2010
by TJ
nice code.
thanks.

Posted: 11 May 2010
by bowlesj3
Very welcome.

Posted: 12 May 2010
by bowlesj3
These Text_GetActive / Arw_GetActive ideas are more useful for the Discretionary Trader.

Regarding my comment above shown below
One final note. I forgot to mention that (with arrows at least) this command can be very useful with arrow manual drops rather than arrows which are preplaced by a study. Generally this would be done with the higher numbered IDs on the chart after all the preassigned IDs are used by studies.
A perfect example of this is shown in the binary search call example scripts.
http://forum.tssupport.com/viewtopic.php?t=6863

(not that example script but the idea) I use to enter RSI values into my secondary program. New arrows are placed each time because I get the cross hair and I often go back to reuse an RSI level. By the end of the day I could have 100 arrows on my chart in subchart #2. Arw_GetActive is used to detect a new arrow. I can rehighlight an existing arrow to reuse it. Zoom at times is used to ensure it is placed properly (press ESC to get control back from the zoom). The RSI value at the arrow drop point is shown in the text of the arrow as well as the value being transferred out via a GV.

I have a second study that also uses arrow drops on a different chart. Again at least 100 per day. It is part of my semi-automatic triggering system.

Rgarding Text_GetActive, you can set up coded text boxes on a chart to represent any value from anywhere in any other chart (floating text as I use in a planning area out front). This might be an entry point for you. Just highlight that text and you have entered your entry point into your program (secondary program or MC itself).

Regarding TL_GetActive, at one point I was using a study that places clone lines to get a visual on wave forward momentum reduction. I would use TL_GetActive to send signals to the study to have it manipulate these clone lines in certain ways. I still use the lines but have replaced this with a much better system to control them.

Posted: 13 Jul 2010
by kiasom
Thanks for these examples. This is very valuable and can e.g. easily be adapted for some simple order processing.
Hopefully TSS will soon get the _GetActive functionality restored.

Posted: 13 Jul 2010
by bowlesj3
No Problem. Yes the commands are very useful. You can even use the TL_GetActive in various situations. I am about to put that command to use again.

Posted: 13 Jul 2010
by bowlesj3
Note that the GetAppInfo commands can at times be used to place text (or line or arrows for that matter) on the chart in certain locations for highlighting. For certain types of use this could be very handy in that it can keep the item out of the way of prices (yet still in view on the chart).

Posted: 20 Jul 2010
by bowlesj3
Here are additional thoughts on how these getactive commands can be used.

My current main use:
Place an arrow on the RSI chart, detect that the arrow is highlighted using the Arw_GetActive command, have the binary search get the RSI value where it is located, put the RSI value in the text of the arrow, use this RSI value somewhere in your study. Maybe this could be an entry point.

Place text on your chart out front to represent a bollinger band from another chart. Highlight this text and use Text_GetActive to detect this. Grab this information and use it somewhere in your study. Maybe this could be an entry point for your trade.

Have a horizontal line on your chart. Highlight this line. Use TL_GetActive to detect this and use its location for yor entry point. Maybe the line could be a stop loss line (whatever).


These are the methods to extend the power of the MC versions of these commands (that I know of).

1/ If you are using an external program to control MC, use a GV that tells the program how to deal with the data obtained from the Highlighted tool (or just the fact that the tool is highlighed). So for example the information from the active arrow in the RSI might have one meaning at one time and a different meaning another time.

2/ along the same line use the color of the tool itself. Your study may put out yellow arrows at one time and red arrows at another time. Or maybe in the future MC will have a custom tool bar that can store predefined tools that you can quickly place on the chart. If you select a yellow arrow definition it tells your Arw_GetActive command one thing but if it is a red arw it tells that command another thing.

3/ I use values as well. If an arrow is active in the RSI it has a value below 200. If it is in the price area of the same chart the arrow has a value greater than 200 so I know that arrow is for a totaly different function (getting high or low of the price bar). Using this method I can use the Arw_GetActive command in two ways on the same chart.

4/ Also the direction of the arrow is used.

Additional thoughts to enhance the the MC interactive power of these commands:

In some cases the fact that the Trader has to unhighlight the tool is very useful. I just programmed an arrow highlight that grabs RSI data. However while it is highlighted I can make adjustments using a GV. Once it is not highlighted it signals MC to run the code to process the data and it resets the adjustment to zero for the next highlighted arrow. Very Powerful stuff.

If MC some day has a timer call to studies (rather than just tick calls) that would increase the power of these commands for better use with slow ticking symbols.

Posted: 24 Jul 2010
by bowlesj3
Because I trade the E-Mini which ticks fast I can use this technique. (Note: the later versions of MC have a command call RecalcLastBarAfter which can force the study to execute every second if you wish and it makes these MC_???_GetActive commands more useful.) I am currently setting up a TL_GetActive command set to activate trade entries when I realize that prices are bouncing off an RSI line running on an angle (rather than horizontal). See the post below for a picture.

I am creating my design ideas here. There will be many updates. I will not post the actual final code of course. I just want others to know what can be done with these MC version getactive commands if one puts one's head to it.

Caution: if you are trading slow ticking symbols this will not work until MC has a way to execute your studies via a timer in addition to trade ticks. There have been many requests for this timer feature. Here is one thread with ideas on that feature.
http://forum.tssupport.com/viewtopic.ph ... light=tick

Note: I completed my coding for the design below. Here are some efficiency observations after using it a while.
1/ Switching to a different angle line to trigger off of is easier ( just click on it and the TL_getactive picks it up).
2/ Hiding a line is just as easy as a regular delete.
3/ Creating a line is easier (You get a readout from the active arrow text).
4/ Removing activation for triggering is easier.
However it is a good 4 days work. Everyone will of course have their own specifics as to how to do it for their setup. As well the design tends to change a bit as you get into the actual coding and think of things. Therefore consider this design for ideas only and to get an idea of what TL_GetActive can do for you.

Design:

EL Code:
on first bar create 5 angle RSI lines so they are ready. They are initially hidden down low horizontally. Store the ID numbers in a table/array. Once the line is placed, in the table/array set the ID numbers to negative to indicate they are hidden. That way you have the actual ID numbers and a way of detecting if they are hidden or not.

Note: in the actual logic I had to rearrange the order of these segements.

External program: (a new angle line on the chart)
**Two arrows have been highlighted on the RSI and using the Arw_GetActive and the binary search routine they pick up the RSI values, the date and the time is also stored.
**You click the "A" button in your external program (or on the MC chart if you want to do it that way). It tells EL to create a line connected between the two arrows. Again the required data from both arrow locations has been stored so the EL code can do this.
**loop the GVs which are reserved for the line coordinates (all 5 lines) and when one is found that is empty load the GVs with the coordinates so EL can move the line in place and mark it as no longer hidden. Note: you need a way to initialize these GVs to zero at the start of the day so the program knows the GVs are empty.

EL processing (a new angle line on the chart)
**On every tick the EL code loops the GV that represents the first line coordinate RSI value to see if a new entry exists, It knows it is new because the ID number will have been set to negative.
**If one is found it changes the ID number to positive and moves the line into place based upon the new coordinates (date,time,value and date,time,value). Most likely date is always today so you do not really need to store this.
**Use the function MoveTrendLine that I created and placed in User Contributed Studies.
**The line is set to yellow because it is visible on the chart but not activated for trigger yet.
**you can repeat this for up to 5 trend lines.

Activate A trend line for trigger.
**Simply click on any line and use the TL_GetActive command to detect you want it to be active for trigger.
**It turns red.
**It immediately calculates the RSI value of the angle line at the current bar (this is also done on every barstatus = 2). This will be your entry point when prices stall at this line.
**Another way is to use the TL_SetAlert and TL_GetAlert commands for trigger.

EL activate (NOTE: you can not activate in the external program)
**Remember you could have 2 or 3 angle lines showing.
**Highlight a different line for active trade entry.
**Note that the GV that had the current active angle RSI line is used to set that line to yellow before the new line is set to active (red).
**it is activated, the GV is set to this value, it changes to red. It calculates the RSI value for entry.
**Note that if you are calculating the value of that line at the current bar to use for entry then you can do this for the line that is red.

EL processing (hide line)
**Highlight the line and it grabs the ID.
**You just highlight the line & move any coordinate off the RSI range (below 0 or above 100). Your code tests 0 and 100 for both ends of the line.
**It hides it and sets the ID in the table to negative so it has a way to know it is hidden. The first coordinate value GV needs to be set to zero too.

External Program (deactivate line)
**Highlight an arrow and it is picked up in the external program. There is a GV containing the currently active angle RSI. Set this to negative from the external program because the external program thinks there is a new RSI level for trade entry.
**The EL code detects that the GV is negative. Therefore the angle RSI line is directly change to yellow. However the line is left on the chart (not hidden). Once this is done the Active angle RSI GV has to be set to zero.

EL processing (adjust line)
**Just highlight the line and move it.
**Once you are finished you remove the highlight by clicking the chart.
**When you unhighlight the line it detects the line is adjusted rather than deleted. It makes it red to indicate it is active.
**It updates the GVs and immediately calculates the new end value of the current bar. It is the active RSI entry for now.
**If you want a different line active you just highlight that line instead.

Notes:

you need to store the active angle RSI line ID so that during some operations above you know if you should change a line that was red to yellow. Also it can be used to reset the line to Red if MC goes down.

It also has occured to me that both when the external program changes the RSI for triggering or you highlight an arrow to use a different RSI for triggering if the GV that stores the active angle RSI is greater than zero you must set it to negative. This way the external program knows to stop using the angle calculation for its RSI and to instead use the RSI obtained from the highlighted arrow.

Special Note:
If you mark waves manually as I do (on all sizes of chart right up to 60 minute bars) you can have the data brought in to the 1 minute bar chart to make an attempt to place these lines if it thinks it might be realistic. If you use an external program as I do You can get notice of this attempt and 1/ reject or 2/ accept the line from that program or 3/ make a few varied attempts to place the line, etc. Last but not least if required you can use the above design to adjust the line after the fact. I got this to work. It can be useful at times. You need to find the date and time and value of the larger chart wave top/bottom, bring it into the smaller chart study via GVs, use my binary search to get the offset then use this command format to get the actual smaller bar offset you want. Note: These comands are put in the 1 minute bar chart.
1MinBaroffset = HighestBar(High,LargerBarSize)[LargerBarBinarySearchOffset];
1MinBaroffset = LowestBar(Low,LargerBarSize)[LargerBarBinarySearchOffset];
If the larger bars are 15 minute bars then LargerBarSize is 15.
The LargerBarBinarySearchOffset will point at the last 1-minute bar in the larger bar.
The 1MinBaroffset will end up with the exact high or low offset for that top/bottom.
Note that you can study the highestBar routine and make your own copy and tweek it.

Posted: 24 Jul 2010
by sptrader
Bowlesj3: I enjoy your posts but I'm a visual guy (and also trade ES), any chance of some chart examples of what you're doing ?

Posted: 24 Jul 2010
by bowlesj3
The angle lines I am referring to are mentioned in the book by John Hayden "The 21 Irrefutable Truths Of Trading" (great book!). They are in the RSI (generally the 1-minute bars). However sometimes in the 10 second bars. I am sure they exist elsewhere at times but it is probably because of the day traders that they are most likely found in the 1-minute bars of the e-mini

The Friday 2010/07/23 e-mini is one of the more perfect examples, which gives a picture.

Re: Base Logic for Interactive Text Script: Likely of use to

Posted: 11 Aug 2010
by sptrader
I know it's a little late for this- but thanks for the visual !

Re: Base Logic for Interactive Text Script: Likely of use to

Posted: 13 Aug 2010
by bowlesj3
Your welcome.

Re: Base Logic for Interactive Text Script: Likely of use to

Posted: 13 Sep 2010
by bowlesj3
Here is a new script that uses these older version commands. I have copied the documentation directly out of the script so you can read it and decide if you want to download it.
Written by John Bowles.

This is an Interactive Script for Arrows to place text event markers on your chart
I am submitting this script as a way to promote the use of the old MC version of Arw_GetActive Text_GetActive and TL_GetActive.
I use those older version of these commands extensively. This is one of my new uses.

Purpose/Value:
* To have a very fast way to place text markers (with different codes) on the current viewing area of the chart using arrows moved in place.
These would be text markers for any event you can come up with such as "Breaks, Lunch, Trade Opportunities, Interruptions, etc"
* To be able to retrieve them if MultiCharts goes down.
* To be able to calculate totals off these text markers and send them to GVs.
* To be able to create new events by simply creating new entries in the input file (no program changes needed). 10 can be created now.
* Of course calculations may need program changes unless all your calculations are similar & you create GVs based upon numbers or use arrays.

Value which is NOT currently programmed:
* To be able to hide these text markers on mass by simply turning off the study and bringing them back by turning it on.
It could be possible to switch them all off using a GV switch and bringing them back in the same way. It does not do that at present.
* In time it could be changed to adjust the text distance from price using GetAppInfo(aiHighestDispValue) & aiLowestDispValue

HOW TO USE:
*Start the script. You will hear a ring out sound the first time.
*You will see your control arrows in the top of the chart at current price (one for each text code of the input file).
*You randomly during the day, decide you want to very quickly mark a bar on your chart with a code above / below that bar.
*Choose an arrow with the correct code.
*When you first highlight one of the arrows you will hear a notify sound on the next tick.
*After the notify sound you will get a ding sound on every tick while the arrow is still highlighed. Keep it highlighted.
*Position the arrow where you want the marker. Before you unhighlight the arrow use the cross hair to ensure it is located properly.
*Now click the background text and you will hear a ringout sound after the recalculate executes.
*Next the scipt will place the text where you indicated (along with all prior text you have in the file at that point).
*The arrow will then reappear out front up high on your chart for use the next time.
*Note that this new marker location will have been added to the file C:\TradeEventMarkingCounting.txt so you do not loose the info.

WARNING 1:
You can only use this with MC 6.0 Beta2 and before because the newer versions of the GetActive commands are different.
According to TSS these older MC versions of the GetActive commands will again be available at MC 7.0 some time.
At that point the commands may be diffent and you may need to adjust this script to use them.

WARNING 2:
You need to use this with a symbol that ticks fairly fast such as the E-Mini S&P futures or else you have to use the new RecalcLastBarAfter command to force the study to execute every 1 or more seconds.

WARNING 3:
EL collections and GV 2.2 should be installed.

This script is the exact script I am using. I am a discretionary trader.
My initial use is to quickly mark trade opportunities my system will permit me to take so I can count them and thus rate myself against
My quota percentage of trades I want to try and catch each day. I have a minimum quota I try to obtain each day. A quota helps maintain focus.
I do not have time during the trading day to fiddle with the normal way of dropping a text letter on the chart to mark an opportunity.
This is the solution I came up with to obtain the speed I am looking for. As of 2010/Sep/13 I have used it one day. It works fine so far.

Currently this script demonstrates:
* Arw_GetActive command for user interactive input using MC 6.0 Beta 2 or before (or MC 7.0 if TSS reinstates this command by that time)
* EL collections CSV reading with both text and number input in each record.
* The recalculate command.
* Formatting arrows.

NOTE: The LastBarOnChart section of this code is based upon the base script included in the very first post of this thread.
That base code was initially presented to show users how the Text_GetActive command could be used (give them a starting point).
I actually came back to that base code months later and down loaded it to start building this script.

NOTE: You need to download the binary search commands located at this thread.
viewtopic.php?f=5&t=7749
Consider using the very last post in the thread to download this script. It is a good idea to study it.
This script is for 1 minute bars. Not second bars. Therefore use the binary search which is meant for 1 minute bars.

NOTE: You need to set the MaxBarsBack for this study so that it is far enough back to be able to find the bar where you move the arrows to.
I set my MaxBarsBack to 500 for my 1 minute bars. That means I can place an arrow back 8.3 hours roughly.
If MaxBarsBack is not set large enough the Binary Search function will issue an error when it tries to find the offset for it.
If I remember correctly it will tell you how large to set the MaxBarsBack too. Again study the binary search function.

NOTE: About not using matching record logic:
I originally wanted to use Matching record logic after sorting the input table.
It was meant that I should be able to move the arrow back in any order and the text that marks the
opportunity location would have a proper number in order working forward. This requires a table sort to be done at currentbar=1
and subsequently if it was sorted then matching record logic could be used.
You can not use the EL collections sort commands to sort a complex list of lists. You would have to use a programmed sort like shell sort.
Maybe an EL Collections map could be used with the data and time as the key and the other fields as the trailer fields to the key.
Unfortunately I do not have time to investigate and get this to work (later I may fix this up).
Therefore, for now at least, on every bar on the chart I search the whole table to see if there is a table element matching it.
Later if I can get the table in order at the beginning (at currentbar = 1) I will use matching record logic to speed it up.
IMPORTANT:
Because of my use I restricted the file processing to the current day to speed things up.
Depending on your use you may have to change this to process the whole chart.

INPUT FILES:
This input file has your codes. The zip file has a starting set of two codes for you.
C:\TradeEventLetterCodes.txt

This is the working file that gets the data based upon where you move the arrow to.
C:\TradeEventMarkingCounting.txt

This is an initialize file for the above file. Overlay the above file with this file at the start of the day to clear it.
C:\TradeEventMarkingCounting_Empty.txt

Possible future changes:
*I may change this so I can drag the text codes farther away from price after the fact. Currently adding a new code resets them all.
*I may change this so I can delete a text code after the fact if I do not make the above change.

Re: Base Logic for Interactive Text Script: Likely of use to

Posted: 06 Jun 2011
by bowlesj3
I tried the new MC 7.0 Beta 1 commands MC_TL_GetActive, MC_Text_GetActive and MC_Arw_GetActive. As as of MC 7.0 Beta 1 and later the above scripts need to use these new commands. In MC 6.0 Beta 2 and before you need to use the old commands for the above scripts. Between these two versions of MC you can not use the above scripts.

Re: Base Logic for Interactive Text Script: Likely of use to

Posted: 16 Mar 2014
by bowlesj3
Here are some of the advantages of this technique:
The use of text boxes interactively creates fairly small interactive buttons you can work with to control code. They are small enough you could probably fit about 20 of them across the top of the chart if you wanted. You can also give them short form labels in one or more characters so you remember what they are for if you have a lot of them. They can be made big enough with the font settings to make them easy to click on without missing. If that becomes a problem all you have to do is increase the font size. Placing the text boxes along the top frees up area in the right margin of your chart for all sorts of price related information you might want to put out front of prices. Right off the top I can think that the target line, stop line and entry line are useful things to place out front of prices in the right margin area. I think it is better to have it out front rather than blocking the price bars but it all depends on your exact objective I suppose. I can only think of one negative in the MC_Text_GetActive technique. It is the fact that it is a two click operation. You click the text you want then you wait for the beep and then click the background of the chart to actually trigger the action. However you could trigger the action to occur immediately upon the text being highlighted. Thinking of this two click disadvantage leads to this next idea to fix that small disadvantage.

A new Idea (replacing the MC_Text_GetActive technique with the MouseClickEvents):
You could use the MouseClickEvents technique to click between text boxes lined up across the top of the chart rather than clicking directly on them as you have to do with the techniques described in this thread. This would give you a single click event to activate code. Unfortunately I have no sample code. The MouseClickEvents command came in after my system was finished. Here are the details of this idea. You place text boxes across the top of the chart (bottom too if you want) and click between them rather than on them using your mouse click event commands to detect which text boxes you clicked between. You get the Text Box Codes to remind you of what they mean as well. You use the location of the text boxes to know what to do (maybe always clicking to the right of the one you want). Maybe you want to limit it to clicks above the text box so you can use the mouse technique for other clicks near the chart price bars (clicks below the text boxes if you have them on the bottom). You position the text box so the anchor points is at the bottom of the text so clicking between them anywhere works. You sound a beep so you know it picked up your click. To keep the text boxes in proper horizontal position all you have to do is on every barstatus=2 is move the text boxes one bar forward (see the next post for keeping them in proper vertical position). This idea will only work as a possible replacement idea for the MC_Text_GetActive technique. The arrow version of my original technique using MC_Arw_GetActive is still useful for moving the arrow to somewhere on the chart to signal something to happen there and depending on what arrow you drag you could have any number of things you could do. The advantage of moving an arrow is you may not get the location correct immediately and have to adjust it and it only signals your code into action once you remove the arrow's highlight (In other words, it gives you a chance to verify you have the position correct).

Using the above idea to decide what to do with MouseClickEvent Data:
It occurred to me that you could use the Mouse click event commands to get the date and time for a bar then you could use the technique in the above paragraph to decide what to do with that data. I have never used these commands but I would think you would store the date, time and price in a set of fields and determine they are outside the price range of the text boxes but you hold on to them. You could click over and over again until you are sure you got it correct. You just have to be able to know that the study has picked up your new values so maybe if the value changes you could sound a beep or even create an alert with the results obtained. In time they may have a text to clipboard command for TTS (text to speech) and it would be voiced to you. You then on the next tick get these values again and determine they are within the price range of the text boxes at the top of the chart then you decide between what text boxes and you then decide what to do with the date, time and price data that was stored before which was outside the text box prices.

Re: Base Logic for Interactive Text Script: Likely of use to

Posted: 16 Mar 2014
by bowlesj3
Here is a bit of logic that can be used to position your arrows or text always very near the top of the screen regardless of how you adjust the screen vertically. It will adjust fairly quickly if you use the RecalcLastBarAfter command mention above and set that to one second. ArrowSpace is the distance you want between your text or arrows. The decimal number .03 is the percentage distance you want the text or arrows from the top of the screen.

Code: Select all

ArrowLoc = MinutesToTime(TimeToMinutes(Time) - (ArrowSpace * ArrowNum)); {Space the arrows horizontally}
ScreenValHighest = GetAppInfo(aiHighestDispValue); {Highest price on the screen}
ScreenValLowest = GetAppInfo(aiLowestDispValue); {Lowest price on the screen}
IntractiveArrow_Location = ScreenValHighest - ((ScreenValHighest - ScreenValLowest) * .03);
value1 = Arw_SetLocation(Arw_ID[ArrowNum],Date,ArrowLoc,IntractiveArrow_Location);

Re: Base Logic for Interactive Text Script: Likely of use to

Posted: 03 Jul 2018
by bowlesj3
I finally (many years later) have gotten around to trying the MouseClickDateTime and the MouseClickBarNumber commands. I included a test script shown below and the test results shown at the bottom. To run the test I clicked the mouse once on the bar just before the LastBarOnChart and the backward offset is therefore value 1. In this post I include some observations about using this command for the interactive script which I included in this thread many years ago (you can download it). Just yesterday I used my example script to create an interactive script for placing RSI lines on the subchart #2 but included the MouseClickDateTime command. Some of my observations below come from that experience.

You can use the MouseClickBarNumber in a calculation shown in the script below to replace my binary. I extracted it from the script below.
OffSetSearch = A_FindOffsetViaBinary(MouseClickDate,MouseClickTime,"Test");
This may be useful at times but at other times my function may be better to use if you do not have a BarNumber to work with.

In the interactive text you have to create some space at the end of the chart (5 of 10 bars of it) to place the text. The reason is you need to be able to know that clicking this text is not part of the input to your interactive script but rather an interactive command. You have to test to see if the MouseClickBarNumber is > that the LastBarOnChart bar number or if the MouseClickDatetime is greater than the Datetime of the LastBarOnChart to know if it is a click on the interactive command., So as an example my interactive script puts trend lines on the RSI. If the trend line is horizontal I click once where I want the trend line to start then I click the "H" interactive command out front at RSI value 20 and it immediately places the line perfectly at the RSI swing where I clicked. If the RSI line is on an angle I mouse click the two anchor points I want then click the interactive command labeled "A" which is out front.

The other observation is I have to click a date/time with the mouse in the sub-chart #1 to get the date and time for the RSI which is in sub-chart #2. If I click in subchart #2 it does not provide any data.

The mouse click idea is faster than moving an arrow to the location to mark the spot. However I have a script for marking swings (waves) in the prices. I want a marker for future visual reverence so it is probably better to drop an arrow there. In my case the script already creates the 6 arrows (three pointing down and three pointing up). This script (although it is interactive) is very complex and it is not shown as an example in this thread since it is massive with all sorts of other features thrown in.


that is it for now.

Code: Select all

{A_Test_MouseClickEvents =======================================================}

[ProcessMouseEvents = True];

inputs:
FutureUse(0);

variables:
CurrentBar1BarNumber(0),
LastBarOnChartBarNumber(0),
MouseClickDate(0),
MouseClickTime(0),
OffSetCalc(0),
OffSetSearch(0),
LogFile(""),
LogPath("");

if currentbar = 1 then
begin
LogFile = "A_Test_MouseClickEvents.txt";
LogPath = "C:\Users\John Bowles\Downloads\" + LogFile;
CurrentBar1BarNumber = BarNumber;
end;

If LastBarOnChart then
begin
if MouseClickDataNumber = 1 then
begin
MouseClickDate = JulianToDate(MouseClickDateTime) ;
MouseClickTime = DateTime2ELTime(MouseClickDateTime);
OffSetSearch = A_FindOffsetViaBinary(MouseClickDate,MouseClickTime,"Test");
if OffSetSearch = -3 then {If -3 then the restart of multicharts is so late the text is farther back than the maxbarsback setting}
begin
FileAppend(LogPath,
" Textoffset=-3 " +
" CurrentTime=" +
numtostr(CurrentTime,0) +
NewLine);
end;

OffSetCalc = BarNumber - MouseClickBarNumber + MaxBarsBack;
LastBarOnChartBarNumber = BarNumber;
FileAppend(LogPath,
"5-Min Bars: " +

" Date=" +
numtostr(Date,0) +

" Time=" +
numtostr(Time,0) +

" MouseClickDate=" +
numtostr(MouseClickDate,0) +

" MouseClickTime=" +
numtostr(MouseClickTime,0) +

" CurrentBar1BarNumber=" +
numtostr(CurrentBar1BarNumber,0) +

" LastBarOnChartBarNumber=" +
numtostr(LastBarOnChartBarNumber,0) +

" MaxBarsBack=" +
numtostr(MaxBarsBack,0) +

" MouseClickBarNumber=" +
numtostr(MouseClickBarNumber,0) +

" OffSetCalc=" +
numtostr(OffSetCalc,0) +

" OffSetSearch=" +
numtostr(OffSetSearch,0) +

NewLine);
end;
RecalcLastBarAfter(1);
end;
5-Min Bars: Date=1180703 Time=1305 MouseClickDate=1180703 MouseClickTime=1300 CurrentBar1BarNumber=1 LastBarOnChartBarNumber=527 MaxBarsBack=6 MouseClickBarNumber=532 OffSetCalc=1 OffSetSearch=1