Fastest execution of multiple commands..

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
James9491
Posts: 34
Joined: 18 Feb 2016, 12:10

Fastest execution of multiple commands..

16 Dec 2016, 19:10

The following code is part of a script that controls buying or selling in the stock market. These instructions should be executed as fast as possible.

I am afraid that 'if' commands isn't fast enough..

Maybe 'case' (I remember that once there was such a command) in a loop will be faster, (is it?) or maybe I can gather all the commands in strings and shoot them out in one sequence?

Is there another possibilities?

James

Code: Select all

Multi_Actions:
!F12::		;<ALT><F12>

;	This routine execute multiple commands in one continuance sequence actions (mouse movements, and clicks), triggered by an external event

counter:=0
;	===>> C, D, M, R		;the key_List: single_Click, Double_click, Move, Right_Click
While counter!=-1
	{
	if command%counter%=C
		mouseClick, Left, xPosition%counter%, yPosition%counter%, 1,,,
	if command%counter%=D
		mouseClick, Left, xPosition%counter%, yPosition%counter%, 2,,,
	if command%counter%=M
		{
		Xtemp:=counter+1
		mouseClickDrag, left, xPosition%counter%, yPosition%counter% , xPosition%Xtemp%, yPosition%Xtemp%,,
		counter++
		}
	if command%counter%=R
		mouseClick, Right, xPosition%counter%, yPosition%counter%, 1,,,
	counter++
	command:=command%counter%
	if command%counter%=End
		counter:=-1
	}
if (command0="C" and command1="End")
	soundPlay, %A_WorkingDir%\Sounds\Button.wav, 1 
else
	soundPlay, %A_WorkingDir%\Sounds\M240 Bravo.wav, 1 
xPosition0:=
yPosition0:=
command0=C	;reset to simple single click
command1=End
return
James9491
Posts: 34
Joined: 18 Feb 2016, 12:10

I thought of another way..

18 Dec 2016, 04:40

Ok, It seem as if I asked too difficult question or maybe there isn't any a real good solution to my problem.

Well, I thought of another way to solve this.
The commands to execute are known ahead of time, so I thought to put them in variables, and upon the trigger to execute these variables all in one sequence, one after the other.

The problem is that I don't know how to sent the content of a variable to be executed as if it is a command.

For example:

Code: Select all

Command:=mouseClickDrag, left, 870, 50 , 850, 70,,
SendInput, %Command%
Can this be done somehow?

Thank you,

James
just me
Posts: 9449
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Fastest execution of multiple commands..

18 Dec 2016, 05:05

James9491 wrote:I am afraid that 'if' commands isn't fast enough.
Isn't it actually? Did you test it?
Maybe 'case' (I remember that once there was such a command) ...
No, it never was in AHK.

And no, you cannot execute a command/function stored as a string in a variable directly in AHK 1.1 within the same script.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Fastest execution of multiple commands..

18 Dec 2016, 12:27

certainly your trading platform has a scripting language to automate buying/selling? thats gotta be faster than using ahk

James9491
Posts: 34
Joined: 18 Feb 2016, 12:10

Re: the trading platform vs the AHK possibilities

19 Dec 2016, 01:31

Sure, but they are very basic and too simple in compare to what I am doing with the AHK script. For instance, with the basic software the Buy or Sell can be triggered only by the stock's price itself, while with the aid of the script, I can track an external index and use it as a trigger to buy or sell.

(and there is more, much more)

James
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: the trading platform vs the AHK possibilities

19 Dec 2016, 09:18

James9491 wrote:Sure, but they are very basic and too simple in compare to what I am doing with the AHK script. For instance, with the basic software the Buy or Sell can be triggered only by the stock's price itself, while with the aid of the script, I can track an external index and use it as a trigger to buy or sell.

(and there is more, much more)

James
my point is, AHK will always be slower than a built-in scripting language, and more error prone, since you are basically just sending clicks to the screen

i would think you may want to move to different platforms that offer more functionality. ive only used NinjaTrader in the past, but i know they have a wealth of free scripts available that can do tons and tons of stuff.

James9491
Posts: 34
Joined: 18 Feb 2016, 12:10

Re: Fastest execution of multiple commands..

19 Dec 2016, 12:09

Well, thank you for you good advice, but in my country, I am trading with 'the best' trading platform and apparently it is very poor compare to what your NinjaTrader can do. In my system, there is no scripts, just very few "smart commands".

So smart that I rather use the script instead.

James
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Fastest execution of multiple commands..

19 Dec 2016, 12:45

James9491 wrote: I am afraid that 'if' commands isn't fast enough..
If your script works, it is not the if ... lines that takes a significant time to execute.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: prototype_zero and 319 guests