[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 358

 

Man, the code itself takes two lines!

if(S_M_0>S_S_0 && S_M_2<S_S_2)
OrderSend("XAUUSD",OP_BUY,1,Ask,10,Bid-200*Point,Ask+100*Point,0);

if(S_M_0<S_S_0 && S_M_2>S_S_2)
OrderSend("XAUUSD",OP_SELL,1,Bid,10,Ask+200*Point,Bid-100*Point,0);


How to fix it? I don't get it.
 
Noterday:

Man, the code itself takes two lines!

What was the swap at the time the order was closed? You have an order rolled over to the next day. For that you get a positive or (more often) a negative swap.
 

With one lot, such a swap is simply not realistic. On another test lot the position opened and closed on the TP on the same day without a rollover, and the result is the same.

Ok, thanks for the quick help, I'll leave that question until tomorrow :)

 
GygaByte:

Wrote just 1 line in EA - Alert output:

Putted on the tool - at least 1 alert came out...

Yes, the ticks are coming, the market is alive
 

See here, removed TP and SL. Closing takes place only by condition.

I have removed conditions for Sell, to check only for Buy.

As a result, all deals are visually closed with profit, judging by the chart, and the history turns out to be minus!


 

By the way, it works as prescribed on EURUSD, but there's a problem with gold.

Maybe I didn't take something into account?

 

Checked in another terminal, everything is fine.

Apparently there is something wrong with the candlestick data in the first terminal. Maybe it's really midnight rolls with a crazy coefficient...

 

Good day to all.

The fact that control from the keyboard (e.g. opening an order) is possible has been explained to me and even shown an example. But it's very difficult to understand the tasks of called functions, even without having read their purpose.

I have seen an example of such a task in somebody else's code and faced the same problem ( I don't know anything about these functions ) Please explain.

Here is an example:

#import "user32.dll"
   bool GetAsyncKeyState(int a0);
   int GetForegroundWindow();
   int GetTopWindow(int a0);
   int GetParent(int a0);
#import

As I understand the GetAsyncKeyState function is responsible for assigning buttons (codes).

I tried to specify the following condition: if (GetAsyncKeyState(88)) OpenBuy(Lots,0,MagicNumber);

No reaction to key X could you write a piece of code for my further study which would execute any action when pressed on the keyboard (with explanations)

And if it's possible for me to get a link to some kind of resource for learning.

P.S. As far as I understand it is a library of the Windows system itself (probably providing a connection between the terminal and the operating system) maybe I'm wrong.

 
Gek34:

Looking at an example of such a task in someone else's code faced this very problem (I don't know anything about these functions), can you explain please?

Key line: #import "user32.dll"

The functions listed below this line in your code, these functions are described in the user32.dll library documentation.

 
Gek34:

Good day to all.

The fact that control from the keyboard (e.g. opening an order) is possible has been explained to me and even shown an example. But it's very difficult to understand the function's tasks without having read their purpose.

I have seen an example of such a task in somebody else's code and faced this very problem ( I don't know anything about these functions ) explain please?

Here is an example:

As I understand the GetAsyncKeyState function is responsible for assigning buttons (codes).

I tried to specify the following condition: if (GetAsyncKeyState(88)) OpenBuy(Lots,0,MagicNumber);

No reaction to key X could you write a piece of code for my further study which would execute any action when pressed on the keyboard (with explanations)

And if it's possible for me to get a link to some kind of resource for learning.

P.S. As far as I understand it is a library of the Windows system itself (probably providing a connection between the terminal and the operating system) maybe I'm wrong.

The highlighted is wrong. Look at MSDN. Here is an example of operation with function GetAsyncKeyState( ):

          if (GetAsyncKeyState(VK_RBUTTON) >> 8) // Если старший бит разрешает, значит клавиша была нажата.
           {
            ... 
           }
Reason: