Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1475

 
MakarFX:

I signed it.

Makar, stop messing with the man's head. He only needs the global level variable and the current price.

input int      Points = 30;
double LoU;

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(Bid-LoU >= Points*_Point)
    {
     OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"300",0);
     Print("---------------------КАЖДЫЙ ТИК ------Tick---------=     "    ,   Tick);
     LoU = Bid; // Здесь вместо Bid можно поставить любую цену
    }
  }

Thus, on each tick the difference of the current price and the price in the LoU variable will be checked and if this difference is equal or exceeds 30 points - the condition is fulfilled, the LoU variable will take a new value and the difference will be checked with a different value.

 
ANDREY:

Here's your code.

But for some reason it doesn't open any orders.

It's opening for me. Check what the log says.


 

Good day!


I am creating an indicator in a separate window. I want to set the initial height of the window, for example 100

We have a standard function:

#property indicator_height  100
IndicatorSetInteger(INDICATOR_HEIGHT, 100)

But they block user height changing, it always stays 100(((( And I really need to be able to change it manually afterwards


Any other options?) So far, I found a wayto simulate throughWinAPI, that we stretch the window with the mouse (and I'm not sure what I can do)

 

Make it so:

IndicatorSetInteger(INDICATOR_HEIGHT, 100);
IndicatorSetInteger(INDICATOR_HEIGHT, 0);
 
alex_xss:

Good day!


Just delete

IndicatorSetInteger(INDICATOR_HEIGHT, 100)
 
There is a subtlety here. First set the size and then reset to zero to release the fixation, which does not change the size. There is no other way around this.
 
Alexey Viktorov:

Makar, stop messing with the man's head. The global level variable and the current price are enough for him.

So, on every tick the difference of the current price and the price in LoU variable will be checked and if this difference is equal or exceeds 30 points - the condition is fulfilled, the LoU variable will take a new value and the difference will be checked with a different value.

You're wrong radically.... Thanks to Makar, I have significantly and most importantly, very effectively broadened my horizons in forex. If not for him I don't know when I would have learned so many useful things for me. I wish there were more of such "managers" on this forum. It was him, and not someone else, who told me that the solution to my problem is the use of EventSetTimer(60) I am very grateful to him for quick and high quality informational support.

And what you advise, I knew it a long time ago and in my code your advice is present from the beginning.
 
Alexey Viktorov:

Makar, stop messing with the man's head. The global level variable and the current price are enough for him.

You never read the topic first and advise what has already been passed

 
MakarFX:

You never read the topic first and advise what's already been done

Agree with you 100%.... no offence to Alexei.....

 
MakarFX:

It works for me. Check what the log says


2021.05.20 06:30:45.176 GBPUSD,M1: 52255 tick events (1440 bars, 53255 bar states) processed in 0:00:00.000 (total time 0:00:05.906)
2021.05.20 06:30:45.163 2010.01.04 00:00:00  ×ÈÑÒÛÉ inputs: Points=30; 
2021.05.20 06:30:45.145 TestGenerator: spread set to 2
2021.05.20 06:30:45.145 TestGenerator: no connect to trade server, default environment will be applied