Any possibility to get the status of the crosshair?

To add comments, please log in or register
Marbo
434
Marbo  

I didn't find any ChartGetInteger() function showing if the crosshair is enabled. Are there other possibilites?

William Roeder
19403
William Roeder  
Marbo: Are there other possibilites?
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.

What are you trying to do?

Marbo
434
Marbo  
William Roeder:
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.

What are you trying to do?

Sorry, I had never thought that my question could lead to misunderstandings. What I want to do is really simple: if the key "A" is pressed, my indicator should check if the crosshair is active/enabled. If yes, a horizontal line should be drawn right where the mouse pointer is. And if the crosshair is inactive, nothing should be done. Simple, but I don't know how to check if the crosshair is active/inactive.

Files:
William Roeder
19403
William Roeder  
Marbo:but I don't know how to check if the crosshair is active/inactive.

You originally stated that "you didn't find any function." So you already know, it isn't possible.

Marbo: Sorry, I had never thought that my question could lead to misunderstandings.

Since it isn't possible, you asked for alternatives. Without knowing what you are trying to do, no alternatives can be guessed.

Marbo
434
Marbo  
William Roeder:

You originally stated that "you didn't find any function." So you already know, it isn't possible.

Since it isn't possible, you asked for alternatives. Without knowing what you are trying to do, no alternatives can be guessed.

Got your point. The only possibility is to offer a job that somebody can solve this problem with a DLL. I hope it's possible to check if the crosshair symbol is clicked. But that's beyond my coding-knowledge.

Keith Watford
Moderator
17599
Keith Watford  
Marbo:

 if the key "A" is pressed, my indicator should check if the crosshair is active/enabled. If yes, a horizontal line should be drawn right where the mouse pointer is. And if the crosshair is inactive, nothing should be done. Simple, but I don't know how to check if the crosshair is active/inactive.

Why do you need to check if the crosshair is active?

Why not have the code draw the line when the "A" is pressed? There would be no reason to press the "A" unless you want the line drawn.

Marbo
434
Marbo  
Keith Watford:

Why do you need to check if the crosshair is active?

Why not have the code draw the line when the "A" is pressed? There would be no reason to press the "A" unless you want the line drawn.

My indicator does the following: when I press 'A' a horizontal line is automatically printed at the high or the low of the candle where the mouse is at the moment. If the mousepointer is closer to the high of the candle the line is printed at the high and if the mousepointer is closer to the low it will be printed at the candle's low.  That's pretty useful for me because most of the time I place lines at the highs and lows of candles.

But sometimes I place lines "somewhere" in the chart which have nothing to do with with the candle position I receive with ChartXYToTimePrice().

And if I have a bool-function which shows me if the crosshair is enabled I know which line should be printed. Of course I could also use other keys but I already use lots of them in my indicator and I hoped it's possible to check the crosshair's status easier.

Marbo
434
Marbo  
Marbo:

My indicator does the following: when I press 'A' a horizontal line is automatically printed at the high or the low of the candle where the mouse is at the moment. If the mousepointer is closer to the high of the candle the line is printed at the high and if the mousepointer is closer to the low it will be printed at the candle's low.  That's pretty useful for me because most of the time I place lines at the highs and lows of candles.

But sometimes I place lines "somewhere" in the chart which have nothing to do with with the candle position I receive with ChartXYToTimePrice().

And if I have a bool-function which shows me if the crosshair is enabled I know which line should be printed. Of course I could also use other keys but I already use lots of them in my indicator and I hoped it's possible to check the crosshair's status easier.

I just found a piece of code which changes the current chartwindow's timeframe by using the user32.dll's PostMessageA function.

So if I can virtually press these window-buttons (M1-MN1) I think there could also be a user32.dll function to check which window-buttons are enabled/disabled/pressed. Is that possible?

#import "user32.dll"
   int   PostMessageA(int hWnd, int Msg, int wParam, int lParam);
   int   GetWindow(int hWnd, int uCmd);
#import

void switchPeriod (int period) {
   if (period==_Period) return;
   int winTF=0;
   switch (period) {
      case PERIOD_MN1: winTF = 33334;  break;
      case PERIOD_W1 : winTF = 33141;  break;
      case PERIOD_D1 : winTF = 33134;  break;
      case PERIOD_H4 : winTF = 33136;  break;
      case PERIOD_H1 : winTF = 35400;  break;
      case PERIOD_M30: winTF = 33140;  break;
      case PERIOD_M15: winTF = 33139;  break;
      case PERIOD_M5 : winTF = 33138;  break;
      case PERIOD_M1 : winTF = 33137;  break;
   }

   int window = GetWindow (WindowHandle(_Symbol, _Period), 0); 
   PostMessageA(window, 0x0111, winTF, 0);
   PostMessageA(window, 0x0100, 0x23, 0);
}
To add comments, please log in or register