Mac Automator to check screen colors - automator

Is there a way Mac Automator can check screen color at a certain pixel?
I have googled this problem and the only thing I found is by using applescript to take a screenshoot. (Which is not sufficient as it’ll save me a photo everytime it excutes. :|
Thanks.

This solution may work for you. Using terms from the (FREE) AppleScript Toolbox scripting addition, to set your mouse location and click at that specified coordinate... You can save this following code I just wrote, in AppleScript editor as an application.
set xyCoordinates to {}
activate
set temp to words of text returned of (display dialog ¬
"Please Enter Your X And Y Coordinates" default answer ¬
"250, 250" buttons {"Cancel", "OK"} ¬
default button 2 ¬
cancel button 1 ¬
with title "Get RGB Color Value") as list
repeat with i from 1 to count of temp
set thisItem to item i of temp
set end of xyCoordinates to thisItem as integer
end repeat
set theIcon to path to resource "AppIcons.icns" in bundle application "Digital Color Meter"
activate application "Digital Color Meter"
delay 1
AST set mouse point location xyCoordinates
tell application "System Events" to tell process "Digital Color Meter"
set resultUIElementList to click at xyCoordinates
delay 1
keystroke "C" using {shift down, command down}
end tell
delay 1
set colorValue to words of (the clipboard) as list
delay 1
activate
display dialog ("Your RGB Values Are " & return & (item 1 of colorValue) & " " & (item 2 of colorValue) & " " & (item 3 of colorValue)) ¬
buttons {"OK"} default button "OK" with icon theIcon giving up after 5
quit application "Digital Color Meter"

Related

Adjust Threshold Within Macro ImageJ

I'm looking to write a macro which requires user input to segment kidneys through thresholding. I'm currently running this:
selectWindow("Cortex");
//run("Threshold...");
title = "WaitForUserDemo";
msg = "If necessary, use the \"Threshold\" tool to\nadjust the threshold, then click \"OK\".";
waitForUser(title, msg);
While the thresholding colour appears, there is no option here to adjust the threshold as the user. Does anyone know how I can get the user to be able to adjust the threshold without having to click "Image -> Adjust - > threshold" each time?
Thanks!

PineScript is exiting strategy and opening a double sized order on the same bar

Using the pinescript editor in TradingView, I've noticed a slightly strange occurrence. When there are triggers to exit a long trade (trailing stop) and a trigger to enter a new short trade on the same bar, both open, however, the short has 2x the position size than it should.
Here's the relevant code:
// When uptrend, use upper band as a stop market buy
if (uptrend)
strategy.entry("Long", strategy.long, stop = h)
// Exit longs with a trailing stop. Assume longStopPrice is calculated per bar
if (strategy.position_size > 0)
strategy.exit("Trailing Stop", "Long", stop = longStopPrice)
// When downtrend, use lower band as a stop market sell
if (downtrend)
strategy.entry("Short", strategy.short, stop = l)
// Exit shorts with a trailing stop. Assume shortStopPrice is calculated per bar
if (strategy.position_size < 0)
strategy.exit("Trailing Stop", "Short", stop = shortStopPrice)
Here is the output on the UI:
Notice that the long position size is 15.358918 and a few bars later, this is closed with a trailing stop size -15.358918. However a new short trade is also opened on the same bar size -30.70059 (It should not be -30 it should be -15).
A little bit later on this second trade is closed by trailing stop, size +15.34 (but -30 was opened).
The strategy leaves you net short -15 units for the entire duration of the backtest. Ideally i'd like the strategy.enter to only enter a single position size & trailing stop to close the entire position, not to enter a double position & close half.
Any ideas?
Its because your exit condition does not have the same id as the entry condition. For TV, the entry id has still not closed. So, change the exit id from 'Trailing Stop' to 'Long' and 'Short' as those are the ids used during the entry.
Theres some logic behind but this happens when you dont close a position before opening a new one, what helped me was just moving the close strategy above the open, so every loop also checks to confirm to always close a position before opening a new one
Btw, also dont forget that on one way mode position your 2nd trade must have to be 2x the previous one, since lets say you go +$25 long, then -$25 for short, you would end with $0 for the next trade. Then having 2x the previous one, you would go +$25 long, then -$50 for short, you would end with -$25 short for your next trade, then +$50 long again you would end +$25 next trade
add to if downtrend this--
and strategy.position_size == 0

Open a trade when an indicator places an arrow in a chart

Is it possible for an EA to open a trade when an indicator places an arrow on the current candle or a previous candle? If yes, how?
I have an indicator that places an arrow where a trade say a BUY or a SELL can be placed. I know that we use code below to get the values of the signal.
double signal_v = iCustom(Symbol(),PERIOD_M1, "My Custom Indicator", 0, 1);
The indicator in this question places an arrow, and I want to know if there is a way one can tell if an arrow has been placed on the current or previous candle by this specific indicator. I have seen any sample codes so I was asking. Kindly.
1 in your example is number of bar (0 - current, 1 - previous one), 0 is the buffer.
For sure you will have at least two buffers if arrows are implemented from buffers (easy to check - open chart and delete all objects. if arrows stay there - then indicator has buffers and arrows are based on buffers. Open data window and check the bar that has an arrow - it must have value in some buffer line that is not zero and not empty, you can compare to other bars with no buffers.
Do not forget that you have to pass all indicator inputs after "My Custom Indicator" otherwise you will upload the indicator with default settings, not what you need.

Are MT4 Strategy Tester backtest results panel dates somehow linked with MT4 Graph?

when I see the backtest results, there is a Result panel( Ref. e.g.: https://quivofx.com/wp-content/uploads/2015/02/result.png )
that listed all transactions for the backtest.
Is there a way to quickly scroll to the relevant portion of the graph?
For example, say buy on 2017.05.03 10.30 EURUSD 5 Min, I would scroll to that portion by just e.g., double click on the entry?
Currently, it is pretty slow for me to go back and forth to check for result entries by scrolling the Graph manually.
double click on trade entry or modification or exit and you will see that picture (of course if you ran the test with visual mode=true)
press space bar and type data and time then press enter - you will see that the chart moves to the indicated date
Another fast & built-in method available:
The fastest jump to an exact datetime value in the MT4 Graph works via the mouse double-click inside the graph's time scale area, near the lower-left corner, where a small gray triangle is present.
A mouse, positioned there for a while, shows a self-explanatory label Double click for editing
Next, one may type-in or copy/paste there any datetime target as one wishes to move to.
2016-12-12 08:00
and hit ENTER
So,
1) using mouse-select ( over a legitimate datetime value as seen in Strategy Tester results et al )
2) Ctrl-INS to copy into a paste buffer
3) Alt-TAB to get into MetaTrader Terminal 4 Graph, if Results were copied from WebBrowser, not from a Strategy Tester sub-window panel in MT4
4) using a mouse-doubleclick activate the datetime entry field as explained above
5) Shift-INS to paste the paste-buffer content
6) ENTER & voila, you are there.

Use "Run AppleScript" inside Automator to continue image manipulation

I'm using Automator for the first time, trying to manipulate (resize and pad) many images at once. I've created a workflow that consists of several actions and an AppleScript at the end to perform some basic If/Then logic (since my images are in different orientations, and need to be padded accordingly).
Here is my workflow (screencap):
And, my crappy AppleScript:
on run {input, parameters}
set this_image to input
set target_H to 600
try
tell application "Image Events"
-- start the Image Events application
launch
-- extract the properties record
set the props_rec to the properties of this_image
-- get dimensions of the image
copy (dimensions of props_rec) to {W, H}
-- determine the shortest side and then
-- calculate the new length for the longer side
if W is greater than H then
set pad_dimensions to {W, 600}
set the scale_dimension to target_H
end if
-- perform action
pad this_image to dimensions pad_dimensions with pad color {255, 255, 255}
-- save the changes
save this_image with icon
-- perform action
scale this_image to size scale_dimension
-- save the changes
save this_image with icon
-- purge the open image data
close this_image
end tell
on error error_message
display dialog error_message
end try
return input
end run
I just want to continue making changes to the same image I started with in the automator workflow, but can't seem to keep going when I switch to AppleScript. Thanks in advance for your time/help!
I only looked at the first 2 lines of your code and spotted a common error. Notice your first action "Ask for Finder items". Notice "items", it's plural. Even though you select only 1 image file you will get back a list which can hold many image files. So your list will hold only one item but it's in a list. That list is passed to "Copy Finder Items" which is plural too so you're good. The stuff from the first action will be handled properly by the second action... and so on until it hits your applescript.
Now in your applescript a list of items is passed as "input". So your second line of code doesn't get an image, it gets a list. If you want the image from the list you have to get item 1 from the list...
set this_image to item 1 of input
Now you have the image and Image Events can do its thing. I didn't look at your Image Events code but I think you'll have to open this_image first and get properties and resize the opened image. So you probably have to do something like this...
tell application "Image Events"
-- start the Image Events application
launch
-- open the image
set openedImage to open this_image
-- extract the properties record
set the props_rec to the properties of openedImage
And so on. You'll be manipulating openedImage, not this_image, which means you'll need code to save openedImage when you're through.
Good luck.

Resources