[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 106

 
vovan-gogan:
Folks, help: I have a condition in my EA which is to open a Buy position only if the low of the previous candlestick is below all the lows of the previous 40 candlesticks. The question: how to implement this enumeration of previous candlestick's lows and find out if the low of the previous candlestick was below the low of the previous candlestick? I thank you in advance.
int TotalBars = 40; // Общее количество свечей по которым нужно осуществлять перебор
double max=0.0;
double min=100.0;
for(int n=0; n<TotalBars; n++)
  {
  if(High[n]>max) max=High[n];
  if(Low[n]<min) min=Low[n];
  }
MessageBox("Maximum="+max+" Minimum="+min);
 
langolier:

Ai thank you!)
 
langolier:

Mmm... Here's the problem... The data should be updated with every new tick and only for the last 30 bars... I keep the data for some reason
 
sergeev:

Help me find an error!


10
mamba5 18.08.2011 14:23

I am writing an EA based on "Black MACD" strategy:


Currency pair: any

Time frame: 15 and more.

Indicators: EMA(3) EMA(18), RSI(14), MACD(12,26,9)

We remove the signal line of the MACD indicator, all indicators are applied to the Close price indicator.

Buy entry signal: EMA(3) crosses EMA(18) from bottom to top, wait for the MACD to show positive side. If RSI(14) is above the 50 level, then buy. Stop-loss is set at the last local minimum. Exit the trade by reversing the EMA crossover, or use your own approach.

Signal to sell: Reverse situation: Crossing of EMA(3) EMA(18) downwards, wait for MACD to be negative. If RSI(14) is below 50, then buy. Stop-loss is set to the last high.


When compiling the code it says that a bracket is missing. After a long search I seemed to have found where it should be, but after fixing the error I got another 20-30 new bugs. Please, advise me where i missed it. ))) The code is in the attached file.

Attached files:
BlackvMACD.mq4 (5.21 KB) delete
Fixed the compilation errors. I did not look into the correctness of the strategy implementation algorithm.
Files:
 
first_may:


Read: https://book.mql4.com/ru/variables/arrays . It turns out that I can organize a two-dimensional array for three pairs: double Mas_d[3][2] = {1, 0, 2, 0, 3,0};

while keeping in mind that:

the value of Mas_d[1][1] corresponds to e.g. the AUDCAD pair, and Mas_d[1][2] is the value of this pair;

the value of Mas_d[2][1] corresponds for example to AUDCHF pair and Mas_d[2][2] is the value of this pair;

value of Mas_d[3][1] corresponds for example to AUDJPY, and Mas_d[3][2] is the value of this pair,

the array elements retain their values between ticks. And then I will be able to change values of array elements according to the criterion I need. Did I understand correctly what you mean? :)

Yes. The approach may not be the best, but everyone chooses it himself. And then, if necessary, modernize and optimize it! :))

I am in the process of modernising my approach. It's not convenient in some cases! :D

 
MaxZ:

Yes. The approach may not be the best, but everyone chooses it for themselves. And then, if necessary, modernize and optimize it! :))

I am in the process of modernizing my approach. It's not convenient in some cases! :D

I'm a beginner and I tried to write a trial Expert Advisor, but I got a mistake when compiling it " \end_of_program' - ending bracket '}' expected C:\Program Files\ForexClub MT4\experts\trsi01.mq4 (30, 3)" I know I wrote it wrong, could you please tell me where I made mistakes?

//+------------------------------------------------------------------+
//| trsi01.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"

double StopLoss=30;

double TakeProfit=100;

double Lots=0.1;

return(0);


int start()
{
if(iRSI(NULL,0,8,PRICE_CLOSE,0)<30)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point)
{
if(iRSI(NULL,0,8,PRICE_CLOSE,0)>70)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point);
{
return(0);
{

 
acoman:

I am a beginner and I tried to write a trial Expert Advisor, but when I compile it I get the error "\end_of_program' - ending bracket '}' expected C:\Program Files\ForexClub MT4\experts\trsi01.mq4 (30, 3)" I know I wrote it wrong, could you please tell me where the error is?

//+------------------------------------------------------------------+
//| trsi01.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"

double StopLoss=30;

double TakeProfit=100;

double Lots=0.1;

return(0);


int start()
{
if(iRSI(NULL,0,8,PRICE_CLOSE,0)<30)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point)
{
if(iRSI(NULL,0,8,PRICE_CLOSE,0)>70)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point);
{
return(0);
{


The error is that you haven't read the manual from cover to cover. If you opened it at all.

But you obviously missed this section: Conditional operator if - else.

You'd be better off reading the book from cover to cover.

 
Thanks, I'll keep it in mind :). Can you please advise which is the minimum stop loss for a specific currency pair? For example EURAUD - you cannot place a stop loss less than 100 pips, and for the others?
 
first_may:
Thanks, will keep it in mind :). Can you please tell me, which minimum stop-loss has a specific currency pair? For example EURAUD - you can't set stop loss less than 100 pips for EURAUD, and for the others?

https://book.mql4.com/ru/appendix/marketinfo

MODE_STOPLEVEL 14 Minimum allowed stop loss/stake profit level in pips
 

How do you form a binary number, e.g. of 7 digits? And how can it then (for convenience) be converted to a decimal number?

Reason: