A question for MQL experts - page 11

 

Gentlemen coders, please help with a piece of code.

I have an Expert Advisor that works. I need to insert in it a condition to prohibit opening trades.

Condition: If the AO histogram is > 0, then do not allow opening deals until the AO histogram is equal to or greater than 0. Thank you.

 
Voice:

Gentlemen coders, please help with a piece of code.

I have an Expert Advisor that works. I need to insert in it a condition to prohibit opening trades.

Condition: If the AO histogram is > 0, then do not allow opening deals until the AO histogram is equal to or greater than 0. Thank you.


Let the variable double Gist store the value of AO and the variable bool Torg store the flag to allow trading.

The condition is blurred. "If the AO histogram>0, then prohibit the EA from opening trades at all" - in the code this would be if(Gist>0){Torg=false;}. Now, the second part of the condition "Till the AO histogram is equal to or greater than 0" can be written in the code in your case in the following way if(Gist>=0){Torg=false;}

This means that (provided AO >= 0) in the first line of code the permission to trade will be removed if(Gist>0){Torg=false;}, and in the second line of code it will be immediately returned if( Gist>=0){Torg=true;}. If AO > 0, the Torg variable will first be false and then immediately true. You can't do that - it's a violation of the law of logic "If a, then a".

 

Sorry, this is my mistake. If it's more than 0, it doesn't open, if it's less than 0, it opens. Can you tell me, should I put this at the beginning of the code? I'll try to build it.

Could you please tell me how to assign AO values to Gist?

 
Voice:

Sorry, this is my mistake. If it's more than 0, it doesn't open, if it's less than 0, it opens. Can you tell me, should I put this at the beginning of the code? I'll try to build it.

Could you please tell me, how else can I get AO values from Gist?

double iAO( string symbol, int timeframe, int shift)
Calculation of Awesome oscillator.
Parameters:
symbol - Symbol name of symbol, on data of which the indicator will be calculated. NULL means current symbol.
timeframe - Period. Can be one of the periods of the chart. 0 means the period of the current chart.
shift - Index of the value obtained from the indicator buffer (shift relative to the current bar by the specified number of periods back).
Example:
 double val=iAO(NULL, 0, 2);
 
Hello Hello! Can you tell me where to go, (throw the link, the answer, "search in the forum" does not work, and so I'm looking for) to write a little algorithm, an adviser or script, so that works. In short, the essence: to open, Buy, Sell with take-profit, at choice when activated and then you can set the pending in different combinations, step and lot, I think someone will be interested and will know how exactly. Please tell me again who can help? zetveis@mail.ru
 
Skif_7:
Hello Hello! Can you tell me where to go, (throw the link, the answer, "search in the forum" does not work, I'm looking for it) to write a little algorithm, an EA or script, so that works. In short, the essence: to open, Buy, Sell with take-profit, at choice when activated and then you can set the pending in different combinations, step and lot, I think someone will be interested and will know how exactly. Please tell me again who can help? zetveis@mail.ru

here is the link https://www.mql5.com/ru/job
 
sergeev:

here is the link https://www.mql5.com/ru/job
It's genius! You can't really tell. Anyway... I'll tell you a secret, I could have looked up and to the right myself, which I did a long time ago.
 
Skif_7:
I'll tell you a secret, I could have looked up and to the right myself. Which I did a long time ago.
I won't tell anyone about your secret.
 

Hello Professionals! Could you please tell me how to delete a BUY_STOP at new pending order placed by an EA, and how to delete a previous SELL_STOP at new SELL_STOP placed by an EA?

Thank you.

 

For BUY_STOP : (1) find the previous active BUY_STOP (2) delete it.

For a SELL_STOP, it is the same as for a BUY_STOP.

If the answer is annoying, go here : https://www.mql5.com/ru/job

Please.

Reason: