NexusFi: Find Your Edge


Home Menu

 





Design a DayTrader Scalping Order Flow Indicator


Discussion in Traders Hideout

Updated
      Top Posters
    1. looks_one hyperscalper with 136 posts (239 thanks)
    2. looks_two Chof with 22 posts (12 thanks)
    3. looks_3 Connor with 16 posts (8 thanks)
    4. looks_4 justtrader with 14 posts (8 thanks)
      Best Posters
    1. looks_one bobwest with 2 thanks per post
    2. looks_two hyperscalper with 1.8 thanks per post
    3. looks_3 SpeculatorSeth with 1 thanks per post
    4. looks_4 Chof with 0.5 thanks per post
    1. trending_up 46,088 views
    2. thumb_up 328 thanks given
    3. group 55 followers
    1. forum 248 posts
    2. attach_file 80 attachments




 
Search this Thread

Design a DayTrader Scalping Order Flow Indicator

  #61 (permalink)
 hyperscalper 
boise idaho
 
Experience: Advanced
Platform: NinjaTrader C# Custom
Broker: NinjaTrader LeeLoo Rithmic
Trading: Nasdaq Futures NQ/MNQ
Posts: 314 since Apr 2020
Thanks Given: 15
Thanks Received: 522


justtrader View Post
Great suggestions. But first things first. Got to find the triggers then, as you suggested, "marry the analytics with execution.

I am not familiar with sockets and will be willing to learn.

Again, thank you for the offer to assist.

JT

You want to know how to implement a 1:1 unidirectional Socket connection between
say MyAmazingTriggerGeneratingIndicator, and a receiver, like your enhanced Chart Trader
facility?

So that would involve a "Server Socket" and a "Client Socket" where the server side just
reads whatever comes its way (e.g. "Buy" or "Sell" messages) and potentially does
something like initiating a single contract or fixed size position.

If we keep it very simple, then the solution is corresponding much simpler.

What would be your ideal relationship between a signal generating Indicator, and
your Order Entry module?

What are the primary desirable advantages of such a link? Primarily 1) speed, and/or
2) Accuracy, etc... of course it would be...

But, as they say, "Where you can go; depends upon where you start!" meaning that if
this were a "green field" development, then there's be the Indicator part; and then
there's be a Strategy developed; and Socket comms would be integrated into that
design.

But, I don't know how I would integrate a socket listener into a Chart Trader instance,
although many "hacks" are possible. If code could be added to the Chart Trader, then
an incoming message could DISPATCH a User Interface programmatic "Click" action
onto a Buy button or a Sell button. Yes, this is a hack, but such a thing could be
necessary, depending on where we start travelling either 1) the Yellow Brick Road,
or 2) down the Rabbit Hole. LOL There's always a solution; and every case is
different.

Having said all of those obvious things... I'm sure you'll be thinking a bit more
what you'd ideally like to do...

Generally, NinjaTrader's Chart Trader offers what is known as "Managed Order Entry"
which places constraints on Order Processing, kind of like Training Wheels on a kids
bicycle. It's forgiving, avoids things getting out of control, etc. And that's a Good Thing
considering that most users have only simple needs, and don't want to get into
trouble.

The other method of entering Orders is "Unmanaged Order Entry" which permits
FREE entry of Orders, but requires that all of the ways things can "screw up" are
the responsibility of the programmer, who has Total Freedom in Order Entry...
That's a little bit like designing a Bicycle for the Tour de France; many more
considerations, even though the simile quickly breaks down here, and I'm sorry
I used Bicycling as a primitive explanatory tool. LOL

hyperxtrading

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Deepmoney LLM
Elite Quantitative GenAI/LLM
Are there any eval firms that allow you to sink to your …
Traders Hideout
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Futures True Range Report
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
18 thanks
The Program
18 thanks
  #62 (permalink)
 
justtrader's Avatar
 justtrader 
San Francisco, CA
 
Experience: Intermediate
Platform: Ninja Trader, TOS
Trading: es, rty, cl, gc, nq, ym
Posts: 182 since May 2011
Thanks Given: 104
Thanks Received: 173


hyperscalper View Post
You want to know how to implement a 1:1 unidirectional Socket connection between
say MyAmazingTriggerGeneratingIndicator, and a receiver, like your enhanced Chart Trader
facility?

So that would involve a "Server Socket" and a "Client Socket" where the server side just
reads whatever comes its way (e.g. "Buy" or "Sell" messages) and potentially does
something like initiating a single contract or fixed size position.

If we keep it very simple, then the solution is corresponding much simpler.

What would be your ideal relationship between a signal generating Indicator, and
your Order Entry module?

What are the primary desirable advantages of such a link? Primarily 1) speed, and/or
2) Accuracy, etc... of course it would be...

But, as they say, "Where you can go; depends upon where you start!" meaning that if
this were a "green field" development, then there's be the Indicator part; and then
there's be a Strategy developed; and Socket comms would be integrated into that
design.

But, I don't know how I would integrate a socket listener into a Chart Trader instance,
although many "hacks" are possible. If code could be added to the Chart Trader, then
an incoming message could DISPATCH a User Interface programmatic "Click" action
onto a Buy button or a Sell button. Yes, this is a hack, but such a thing could be
necessary, depending on where we start travelling either 1) the Yellow Brick Road,
or 2) down the Rabbit Hole. LOL There's always a solution; and every case is
different.

Having said all of those obvious things... I'm sure you'll be thinking a bit more
what you'd ideally like to do...

Generally, NinjaTrader's Chart Trader offers what is known as "Managed Order Entry"
which places constraints on Order Processing, kind of like Training Wheels on a kids
bicycle. It's forgiving, avoids things getting out of control, etc. And that's a Good Thing
considering that most users have only simple needs, and don't want to get into
trouble.

The other method of entering Orders is "Unmanaged Order Entry" which permits
FREE entry of Orders, but requires that all of the ways things can "screw up" are
the responsibility of the programmer, who has Total Freedom in Order Entry...
That's a little bit like designing a Bicycle for the Tour de France; many more
considerations, even though the simile quickly breaks down here, and I'm sorry
I used Bicycling as a primitive explanatory tool. LOL

hyperxtrading


Thanks for the thought process. That bicycle was a good analogy.

My chart trader, as you might imagine, is using "listeners" to take any action. All the Order activities are under "Unmanaged Order Entry". Hence, any messages detected by a socket listener can be processed just like the button event listeners to process Orders (or I will need to learn also how to fire an equivalent event to the corresponding button). Sounds interesting.

JT

TWYS NWYT (Price Advertises Opportunity; Time Regulates it; Volume Measures its Success/Failure ---- Dalton)
Reply With Quote
  #63 (permalink)
 hyperscalper 
boise idaho
 
Experience: Advanced
Platform: NinjaTrader C# Custom
Broker: NinjaTrader LeeLoo Rithmic
Trading: Nasdaq Futures NQ/MNQ
Posts: 314 since Apr 2020
Thanks Given: 15
Thanks Received: 522



justtrader View Post
Thanks for the thought process. That bicycle was a good analogy.

My chart trader, as you might imagine, is using "listeners" to take any action. All the Order activities are under "Unmanaged Order Entry". Hence, any messages detected by a socket listener can be processed just like the button event listeners to process Orders (or I will need to learn also how to fire an equivalent event to the corresponding button). Sounds interesting.

JT

Yeah, but how do we "inject" the listener Socket code? And the code to "Dispatch"
Button presses onto the GUI thread? etc..... I have no idea; but maybe we
can throw some XML at it, and magically connect, say, to a DLL facility
containing the Socket code?

That would be a Super Hack; however, I'm not familiar with Chart Trader and
it's WPF stuff...

hyperxtrading

Started this thread Reply With Quote
  #64 (permalink)
 hyperscalper 
boise idaho
 
Experience: Advanced
Platform: NinjaTrader C# Custom
Broker: NinjaTrader LeeLoo Rithmic
Trading: Nasdaq Futures NQ/MNQ
Posts: 314 since Apr 2020
Thanks Given: 15
Thanks Received: 522


hyperscalper View Post
Yeah, but how do we "inject" the listener Socket code? And the code to "Dispatch"
Button presses onto the GUI thread? etc..... I have no idea; but maybe we
can throw some XML at it, and magically connect, say, to a DLL facility
containing the Socket code?

That would be a Super Hack; however, I'm not familiar with Chart Trader and
it's WPF stuff...
should
hyperxtrading

justtrader ...

I did a quick search and.....
It looks like this "Rat's Nest" is the one we should be looking at, for possible
Chart Trader enhancements via code injection in XML... ??

https://docs.microsoft.com/en-us/dotnet/desktop/wpf/advanced/code-behind-and-xaml-in-wpf?view=netframeworkdesktop-4.8

Just thinking about it makes me throw up a bit in my mouth; but let's consider that
it could possibly be a way forward, I'd think maybe a DLL could be accessed to
( some-how ) insert Socket comms into Chart Trader as a triggering mechanism...

Let me know when you've done it... I'd prefer "real code" myself... Just kidding; not kidding...

[EDIT] In considering this sort of thing in the past, one of the obvious facilities
would be not to do something like Socket comms to your trade initiator; but
to use AutoHotKey (aka AHK) in the Indicator (using its supported DLL) to click buttons at
specific screen locations, thus automating some of the interactivity; but requiring specific
positioning coordinates for the Chart Trader's UI surface. This can work, and is
probably much less of a hack than code injection attempts via XAML.

[...] I poked around this for a while, a while back, in trying to implement a "shift left" action
on Charts; which NinjaTrader engineering flatly refused to help me with; which is why
I never ask them for code support any more, if I can find any way to avoid it...
If you are looking for selected "One Shot" actions on Chart Trader buttons, then
this is a viable way forward. Specific positioning and sizing constraints would
normally apply, unless a specific internal control handle can be used to find
the control in question (I think unlikely). Coordinates could be held in a file, etc.,
but AHK has been around for decades so it quite well developed and supported,
and there is a supported DLL which is easily accessed from C# code in the
originating signal-generating Indicator code, over which we have control.

hyperxtrading

Started this thread Reply With Quote
  #65 (permalink)
 hyperscalper 
boise idaho
 
Experience: Advanced
Platform: NinjaTrader C# Custom
Broker: NinjaTrader LeeLoo Rithmic
Trading: Nasdaq Futures NQ/MNQ
Posts: 314 since Apr 2020
Thanks Given: 15
Thanks Received: 522

THIS CODE CONTAINS SNIPPETS ILLUSTRATING HOW AHK COULD BE INTEGRATED
WITHIN AN INDICATOR. DO NOT USE THE CODE, EXCEPT AS A ROUGH SAMPLE
OF HOW AHK FUNCTIONS MAY BE ACCESSED FROM AN INDICATOR.

 
Code
#region Using declarations
using System;
using System.IO;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Gui.Tools;
using NinjaTrader.Gui.NinjaScript;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.DrawingTools;
using AutoHotkey.Interop;
#endregion

//This namespace holds Indicators in this folder and is required. Do not change it. 
namespace NinjaTrader.NinjaScript.Indicators
{
	/*
	DO NOT ATTEMPT TO USE THIS CODE; IT LIKELY WILL NOT WORK; BUT
	DOES CONTAIN SNIPPETS FOR THE CURIOUS...
	Installed in NinjaTrader 8\bin\Custom folder are
	* AutoDragLeft.ahk (AutoHotKey script); AutoHotkey.dll
	* and AutoHotkey.Interop.dll files .  This indicator intended
	* to reside on a chart in its own Panel and to initiate a Mouse Drag
	* using AutoHotkey functions when the active bar is near to the
	* right margin to avoid excessive "scroll left" of charts on
	* each bar; instead, this does the "shift left" periodically when
	* necessary, with the hope that most of the charting area to
	* the left of the forming bar will not require much refresh
	* of the image, when viewed using Remote Desktop viewers.
	*/
	public class AutoDragLeftAHK : Indicator
	{
		protected override void OnStateChange()
		{
			if (State == State.SetDefaults)
			{
				Description									= @"Automatically Drag's Indicator Panel chart left.";
				Name										= "@AutoDragLeftAHK";
				Calculate									= Calculate.OnBarClose;
				IsOverlay									= true;
				IsAutoScale									= false;
				DisplayInDataBox							= false;
				DrawOnPricePanel							= false;
				DrawHorizontalGridLines						= false;
				DrawVerticalGridLines						= false;
				PaintPriceMarkers							= false;
				ScaleJustification							= NinjaTrader.Gui.Chart.ScaleJustification.Right;
				//Disable this property if your indicator requires custom values that cumulate with each new market data event. 
				//See Help Guide for additional information.
				IsSuspendedWhileInactive					= true;
				throw new Exception("DO NOT USE THIS CODE");
			}
			else if (State == State.Configure)
			{
			}
			else if (State == State.Realtime) {
				// try to grab Dispatcher
				if (ChartControl != null && ChartControl.Dispatcher != null) {
					_myDispatcher = ChartControl.Dispatcher;
					// will be useful for x,y coordinate mappings
				}
				init();
			}
		}
		
		[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
	    private static extern void mouse_event(uint dwFlags, int dx, int dy, uint cButtons, uint dwExtraInfo);

	    [DllImport("user32.dll")]
	    static extern bool SetCursorPos(int X, int Y);

	    [DllImport("user32.dll")]
	    static extern bool GetCursorPos(ref Point lpPoint);

	    const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
	    const uint MOUSEEVENTF_LEFTUP = 0x0004;
	    const uint MOUSEEVENTF_MOVE = 0x0001;

	    static void Drag(int startX,int startY,int endX,int endY)
	    {
	        endX = endX - startX;
	        endY = endY - startY;
			Point currPos = new Point();
			GetCursorPos(ref currPos);
	        SetCursorPos(startX, startY);
	        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
	        mouse_event(MOUSEEVENTF_MOVE, endX, endY, 0, 0);
	        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
			SetCursorPos((int)currPos.X, (int)currPos.Y);
	    }
	
		private void MyPrint(string msg) {
			if (USE_PRINT) Print(msg);
		}
 
		private System.Windows.Threading.Dispatcher _myDispatcher = null;
		
		private System.Windows.Threading.Dispatcher getDispatcher() {
			if (_myDispatcher==null) {
				throw new Exception("No System.Windows.Threading.Dispatcher");
			}
			return _myDispatcher;
		}
		
		//grab a copy of the AutoHotkey singleton instance
        private AutoHotkeyEngine ahk = null; // in init() AutoHotkeyEngine.Instance;
		private string customRootPath = null; // in init();
		
		int DragFromPct = 10; //  15% to right margin, initiate drag
		int DragBackToPct = 45; // 45% drag to left, leaving 55% of chart to left
		
		private static bool USE_PRINT = true;
		
		private void tempNeverCalled() {
			_myDispatcher = this.Dispatcher;
		}
		
		string hwnd = "none";
		
		private void init() {
			try {
				getDispatcher();
				ahk = AutoHotkeyEngine.Instance;
				customRootPath = Environment.ExpandEnvironmentVariables(
					"%USERPROFILE%\\Documents\\NinjaTrader 8\\bin\\Custom\\");
				if (USE_PRINT) MyPrint("end init");
				// TODO
				MyPrint("loading script");
				ahk.Reset();
				ahk.LoadFile(customRootPath+"AutoDragLeft.ahk"); // script functions
				MyPrint("script is loaded");
				ahk.ExecFunction("InitLoad");
				MyPrint("script initialized");
				hwnd = ahk.GetVar("hwndVar");
				MyPrint("Window handle variable hwndVar is: "+hwnd);
				// want window handle for chart
				DispatcherOperation dispatchOp = getDispatcher().InvokeAsync((Action) (() => {
					// on Windows GUI thread, while we wait
					currentChart = Window.GetWindow(this.ChartControl.Parent) as Chart;
				}));
				dispatchOp.Wait();
				//if (currentChart!=null) {
					//currentChart.
				//}
				loadCoordinates(); // from FileName
			}
			catch(Exception ex) {
				Print(ex.StackTrace);
				ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); // never use throw ex;
				//return;
			}
		}
		
		private DateTime lastDragTimestamp = DateTime.UtcNow;
		private int minDelayMsecs = 3000;

		/*
		public override void OnCalculateMinMax()
		{
			double tmpMin = double.MaxValue; // initialize min and max
			double tmpMax = double.MinValue;
			
			if (Values[0].IsValidDataPointAt(Values[1].Count - 1))
			{
				double bidTmp = Values[0].GetValueAt(Values[1].Count - 1);
				tmpMin = Math.Min(tmpMin, bidTmp);
				tmpMax = Math.Max(tmpMax, bidTmp);
			}
			
			MinValue = -10; //tmpMin;
			MaxValue = 100; //tmpMax;
		}
		*/
		
		// using OnRender only to know when Chart Canvas area needs to be
		// "dragged left" since it is too close to right margin
		protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
		{
			//chartControl
			if (chartControl== null || chartScale==null) {
				return;
			}
			else {
				base.OnRender(chartControl, chartScale);
			}
			if ( BarsArray[0] == null || ChartBars == null) {
				return;
			}
			//if (USE_PRINT) MyPrint("OnRender called");
			if (dragFlag) return; // OnBarUpdate needs to clear this
			DateTime now = DateTime.UtcNow; // real time now
			TimeSpan elapsed = now - lastDragTimestamp; // compare elapsed time
			if (elapsed.TotalMilliseconds < minDelayMsecs) {
				return; // should wait, minimum delay
			}
			// minimum delay has passed
			ChartPanel	panel 	= chartControl.ChartPanels[chartScale.PanelIndex]; // this panel's index
			//float 		endX 	= panel.X + panel.W; // rightmost pixel x coordinate
			
			
			
			{
				float 		dragFromThresholdX 	= (float)(panel.X + (panel.W * (1 - DragFromPct / 100.0))); // where to start drag
				float currentBarX = ChartControl.GetXByBarIndex(ChartBars, BarsArray[0].Count-1);
				if (currentBarX < dragFromThresholdX) return; // don't drag yet
				dragFlag = true; // processed in OnBarUpdate
				// done in OnBarUpdate lastDragTimestamp = now;
				
				// now need to drag, but back to where?
				float 		dragBackToX 	= (float)(panel.X + (panel.W * (1 - DragBackToPct / 100.0))); //drag to this x coordinate
				float 		dragFromX 	= (float)(panel.X + panel.W - 5);
				
				//startPanelX = panel.X + panel.W - 5;
				//startPanelY = 5;
				//deltaPanelX = dragBackToX - dragFromX; // always a negative number, please
				//if (deltaPanelX>0) deltaPanelX=0;
			}
		}
		
		public override void OnRenderTargetChanged()
		{
			// maybe nothing
		}
		
		private bool dragFlag = false;
		
		private double savedMouseX; // save/restore Mouse Position
		private double savedMouseY;
		
		private double startPanelX; // drag Mouse left from this X coordinate
		private double startPanelY;
		private double deltaPanelX; // add this (negative) value for end Drag X (same Y coord)
		
		private string FileName = "DragLeft.txt";
		
		private void loadCoordinates() { //(string fileName) {
			string fullPath = customRootPath + FileName;
			using (StreamReader reader = new StreamReader(fullPath)) {
			string line;
			bool done = false;
			while (!done && ((line = reader.ReadLine()) != null)) {
				string[] items = line.Split(',');
				// 3 comma separated items
				startPanelX = int.Parse(items[0]);
				startPanelY = int.Parse(items[1]);
				deltaPanelX = int.Parse(items[2]);
				MyPrint("Data is startPanelX:"+startPanelX+" startPanelY:"+startPanelY+" delta"+deltaPanelX);
				done = true;
			}
			}
			// no close?
		}
		
		Chart currentChart = null; // fetch by dispatch
 
		protected override void OnBarUpdate()
		{
			if ( dragFlag) {
				if (USE_PRINT) MyPrint("OnBarUpdate (sim) drag from "+DragFromPct+"% to "+DragBackToPct+"% hwnd: "+hwnd);
				DateTime now = DateTime.UtcNow;
				lastDragTimestamp = now;
				dragFlag = false;
				MyPrint("ahk.ExecFunction MouseCustomDrag"+ " |"+startPanelX+ " |"+startPanelY+ " |"+deltaPanelX);
				// save Mouse position
				// move to drag start, and drag left by delta
				// restore Mouse position
				int delta2 = (int)Math.Abs(deltaPanelX); // positive deltax to subtract
				Drag((int)startPanelX, (int)startPanelY, (int)(startPanelX-delta2), (int)startPanelY);
			}
		}
		
		protected /*override*/ void OnBarUpdateX()
		{
			if ( dragFlag) {
				if (USE_PRINT) MyPrint("OnBarUpdate (sim) drag from "+DragFromPct+"% to "+DragBackToPct+"% hwnd: "+hwnd);
				DateTime now = DateTime.UtcNow;
				lastDragTimestamp = now;
				dragFlag = false;
				MyPrint("ahk.ExecFunction MouseCustomDrag"+ " |"+startPanelX+ " |"+startPanelY+ " |"+deltaPanelX);
				// save Mouse position
				// move to drag start, and drag left by delta
				// restore Mouse position
				int delta2 = (int)Math.Abs(deltaPanelX); // positive deltax to subtract
				ahk.ExecFunction("MouseCustomDrag", ""+startPanelX, ""+startPanelY, ""+delta2);
			}
		}
	}
}

#region NinjaScript generated code. Neither change nor remove.

namespace NinjaTrader.NinjaScript.Indicators
{
	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
	{
		private AutoDragLeftAHK[] cacheAutoDragLeftAHK;
		public AutoDragLeftAHK AutoDragLeftAHK()
		{
			return AutoDragLeftAHK(Input);
		}

		public AutoDragLeftAHK AutoDragLeftAHK(ISeries<double> input)
		{
			if (cacheAutoDragLeftAHK != null)
				for (int idx = 0; idx < cacheAutoDragLeftAHK.Length; idx++)
					if (cacheAutoDragLeftAHK[idx] != null &&  cacheAutoDragLeftAHK[idx].EqualsInput(input))
						return cacheAutoDragLeftAHK[idx];
			return CacheIndicator<AutoDragLeftAHK>(new AutoDragLeftAHK(), input, ref cacheAutoDragLeftAHK);
		}
	}
}

namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
	{
		public Indicators.AutoDragLeftAHK AutoDragLeftAHK()
		{
			return indicator.AutoDragLeftAHK(Input);
		}

		public Indicators.AutoDragLeftAHK AutoDragLeftAHK(ISeries<double> input )
		{
			return indicator.AutoDragLeftAHK(input);
		}
	}
}

namespace NinjaTrader.NinjaScript.Strategies
{
	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
	{
		public Indicators.AutoDragLeftAHK AutoDragLeftAHK()
		{
			return indicator.AutoDragLeftAHK(Input);
		}

		public Indicators.AutoDragLeftAHK AutoDragLeftAHK(ISeries<double> input )
		{
			return indicator.AutoDragLeftAHK(input);
		}
	}
}

#endregion
Ths local AHK scripting support file was:

 
Code
; for use with Indicator AutoDragLeft
CoordMode, Mouse, Screen
oldX := 0
oldY := 0
; wintitle := "title"
hwndVar := 0
x2 := 0

InitLoad()
{
	global
	WinGet, hwndVar, ID
}

MouseCustomDrag(x, y, dx) 
{
	global
	WinActivate, ahk_id, %hwndVar%  ; from init
	MouseGetPos, oldX, oldY  ; save current mouse
	x2 := (x - dx) ; subtract for new x coord
	MouseMove, x, y
	MouseClickDrag, L, x, y, x2, y ; mouse left button drag
;	MouseMove, oldX, oldY ; restore original position
}
DrafLeft.txt just contained a few numbers:

 
Code
1180,900,100
...for justtrader to look at:

This code is a mess because it switches and mixes AHK external functions,
with Win32 calls; in a (failed) attempt to get to a satisfactory solution to "drag left"
for chart panels; an issue which I "gave up on" and got no help from Ninja support
despite going to management... can't win 'em all

This code was part of my research, which was later discontinued. But it does illustrate
that "automated button clicks" or other actions via AutoHotKey (aka AHK) can easily
be embedded within an Indicator.

Perhaps, avoiding AHK; just Win32 Mouse functions are sufficient in the end...
so there are alternatives for accomplishing what is desired with Mouse actions, despite
the fact that it is often "brittle" as a general solution...

...but it is true that...
This facility, AutoHotKey has a supported DLL and has been around for decades,
as a solution broadly to automating user interface actions.

As they say, "Don't try this at home, kidz" -- just kidding... LOL

hyperxtrading

Started this thread Reply With Quote
  #66 (permalink)
 
justtrader's Avatar
 justtrader 
San Francisco, CA
 
Experience: Intermediate
Platform: Ninja Trader, TOS
Trading: es, rty, cl, gc, nq, ym
Posts: 182 since May 2011
Thanks Given: 104
Thanks Received: 173

@hyperscalper
WoW,

This is heavy stuff.

Thank you for all that hard work. Hopefully it will get us somewhere beyond what you have accomplished thus far.

JT

TWYS NWYT (Price Advertises Opportunity; Time Regulates it; Volume Measures its Success/Failure ---- Dalton)
Reply With Quote
  #67 (permalink)
 hyperscalper 
boise idaho
 
Experience: Advanced
Platform: NinjaTrader C# Custom
Broker: NinjaTrader LeeLoo Rithmic
Trading: Nasdaq Futures NQ/MNQ
Posts: 314 since Apr 2020
Thanks Given: 15
Thanks Received: 522


justtrader View Post
@hyperscalper
WoW,

This is heavy stuff.

Thank you for all that hard work. Hopefully it will get us somewhere beyond what you have accomplished thus far.

JT

Yeah, but I can see now that an Indicator on the same Chart as
the ChartTrader being used, has direct access to the WPF controls.

That means that there is no need for interprocess communication.

This makes a solution much simpler; and a "shell" indicator that
may enhance the ChartTrader GUI (like you've done)
could simply "host" or "embed"
the type of Indicator we've been discussing here (which generates
"signals") which could be could be integrated to activate Trades...

So it's not the Nightmare I originally imagined; and I'm something
of a "master" at "embedding" Indicators within a much larger
execution context; not by referencing them (the NinjaTrader way)
but by inserting the code and driving data into them thus escaping
from the "limitations" inherent in the standard Indicator model.

If that made no sense to you; it's cuz nobody does it... LOL but
I'd say the path forward from IndicatorEmbedded to sending events
to ChartTrader is relatively straightforward...?

hyperscalper

Started this thread Reply With Quote
  #68 (permalink)
 
lolu's Avatar
 lolu 
Lagos, Nigeria
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader, SierraChart
Trading: Euro Currency & Oil
Frequency: Daily
Duration: Hours
Posts: 2,552 since Jun 2009
Thanks Given: 1,049
Thanks Received: 1,678


hyperscalper View Post
THIS CODE CONTAINS SNIPPETS ILLUSTRATING HOW AHK COULD BE INTEGRATED
WITHIN AN INDICATOR. DO NOT USE THE CODE, EXCEPT AS A ROUGH SAMPLE
OF HOW AHK FUNCTIONS MAY BE ACCESSED FROM AN INDICATOR.


Ths local AHK scripting support file was:

 
Code
; for use with Indicator AutoDragLeft
CoordMode, Mouse, Screen
oldX := 0
oldY := 0
; wintitle := "title"
hwndVar := 0
x2 := 0

InitLoad()
{
	global
	WinGet, hwndVar, ID
}

MouseCustomDrag(x, y, dx) 
{
	global
	WinActivate, ahk_id, %hwndVar%  ; from init
	MouseGetPos, oldX, oldY  ; save current mouse
	x2 := (x - dx) ; subtract for new x coord
	MouseMove, x, y
	MouseClickDrag, L, x, y, x2, y ; mouse left button drag
;	MouseMove, oldX, oldY ; restore original position
}

@hyperxtrading,

I suppose that the above code is the AutoDragLeft.AHK. Meanwhile, could you please give us the links where we can get AutoHotkey.dll and AutoHotkey.Interop.dll files.

Lolu

Visit my NexusFi Trade Journal Reply With Quote
  #69 (permalink)
 hyperscalper 
boise idaho
 
Experience: Advanced
Platform: NinjaTrader C# Custom
Broker: NinjaTrader LeeLoo Rithmic
Trading: Nasdaq Futures NQ/MNQ
Posts: 314 since Apr 2020
Thanks Given: 15
Thanks Received: 522


lolu View Post
@hyperxtrading,

I suppose that the above code is the AutoDragLeft.AHK. Meanwhile, could you please give us the links where we can get AutoHotkey.dll and AutoHotkey.Interop.dll files.

Lolu

There is a huge mature community about AutoHotKey and how to get files.

Just start searching for it...

hyperscalper

Started this thread Reply With Quote
  #70 (permalink)
 
lolu's Avatar
 lolu 
Lagos, Nigeria
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader, SierraChart
Trading: Euro Currency & Oil
Frequency: Daily
Duration: Hours
Posts: 2,552 since Jun 2009
Thanks Given: 1,049
Thanks Received: 1,678



hyperscalper View Post
There is a huge mature community about AutoHotKey and how to get files.

Just start searching for it...

hyperscalper

@hyperscalper,

I got AutoHotkey.dll but I'm still unable to find AutoHotkey.Interop.dll.

What about my question on AutoDragLeft.AHK above ?

Lolu

Visit my NexusFi Trade Journal Reply With Quote




Last Updated on January 26, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts