[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 313

 
trader_john:

Can you tell me what could be causing this glitch?

It works, works, everything is fine, then suddenly, all of a sudden :-(

And, not just dots are drawn where they should not be, but the data window also shows incorrect data (pertinent to the location of the dots)

(The indicator shows extrema, I wrote it myself )

After "rewinding" of a timeframe everything becomes normal

Maybe you know where to "dig". Or maybe there is such a topic on the forum.

Thanks in advance!


Write a proper indicator and the problems will disappear
 
Vinin:

Write a proper indicator and the problems will disappear


How do you mean by normal? If I knew that, I would not be asking questions here.

By the way, the Fractals indicator that I downloaded in MQL "does the same thing".

https://www.mql5.com/ru/code/7982

So it's not written correctly either?

 
trader_john:

Can you tell me what could be causing this glitch?

It works, works, everything is fine, then suddenly, all of a sudden :-(

And, not just dots are drawn where they should not be, but the data window also shows incorrect data (pertinent to the location of the dots)

(The indicator shows extrema, I wrote it myself )

After "rewinding" of a timeframe everything becomes normal

Maybe you know where to "dig". Or maybe there already is a topic on the forum.

Thanks in advance!

Wrote a similar one, it happened the same way as yours. I noticed that if indicator is calculated longer than one tick, there is no doubling. You may need to add heavier condition or sleep. But I am not a programmer, just an observation.
 
Operr:
I was writing a similar one, it happened the same as yours. I have noticed, if indicator is calculated longer than one tick, there is no doubling. Add a heavier condition or sleep. But I am not a programmer, just an observation.


Didn't quite get it. maybe "calculates on more than 1 bar?"

Remembered Fractals (MQL4) / I reworked it to start counting from bar 3. I.e. 2 bars should end after it,

In the original indicator, it used to draw a "point"...I think it was on bar #2...(i.e. zero bar was also considered)

But if this point was broken before 2 bars, it stayed there...

and it turned out that there were no two bars lower on the right, while the upper fractal was drawn.

Built in fractals removes by the way...

Ok... I'll think about it.

 
Operr:
Add a heavier condition or sleep.
For information - Sleep does not work in indicators.
 

How do I make the MA count one for high and one for low?


// Trading criteria
MA_1_t=iMA(NULL,0,Period_MA_1,0,MODE_LWMA,PRICE_TYPICAL,0); // MA_1
MA_2_t=iMA(NULL,0,Period_MA_2,0,MODE_LWMA,PRICE_TYPICAL,0); // MA_2
MA_3_t=iMA(NULL,0,Period_MA_3,0,MODE_LWMA,PRICE_TYPICAL,0); // MA_3

if (MA_2_t > MA_3_t + Rastvor*Point) // If difference between
{ // .MA_2_t + Rastvor*Point { .MA 2 and 3 large
Opn_B=true; // Open Buy Criterion
Cls_S=true; // Close Sell Criterion } (MA_2_t + Rastvor*Point) if (MA_2_t > MA_3PICAL) Sell
}
if (MA_1_t < MA_3_t - Rastvor*Point) // If difference between
{ // ..MA 1 and 3 is big
Opn_S=true; // Criterion open Sell
Cls_B=true; // Criterion closed Buy Cls_B=true; // Criterion closed Sell } } Sell only // MA 1 and 3 is big. Buy

}



I want MA_1 to be set to High and MA2 to be set to Low

MA_2 be set to Low

MA_3 must be set as Close

And how to set all moves to be SMA

 
NROST:

How do I make the MA count one for high and one for low?


// Trading criteria
MA_1_t=iMA(NULL,0,Period_MA_1,0,MODE_LWMA,PRICE_TYPICAL,0); // MA_1
MA_2_t=iMA(NULL,0,Period_MA_2,0,MODE_LWMA,PRICE_TYPICAL,0); // MA_2
MA_3_t=iMA(NULL,0,Period_MA_3,0,MODE_LWMA,PRICE_TYPICAL,0); // MA_3

if (MA_2_t > MA_3_t + Rastvor*Point) // if difference between
{ // ...MA_2 and 3 is large
Opn_B=true; // Open Buy criterion
Cls_S=true; // Close criterion Sell
}
if (MA_1_t < MA_3_t - Rastvor*Point) // If difference between
{ // ...MA_1 and 3 is large
Opn_S=true; //open Sell criterion
Cls_B=true; //Click criteria Buy

}



I want MA_1 to be set to High and MA2 to be set to Low

MA_2 be set to Low

MA_3 must be set as Close

And how to make all zones to be SMA



All the answers are in there
 
Vinin:

All the answers are in there.
thanks
 

Folks, your help is needed.

There are trading conditions, defined as: Buy if %D line of stochastics crosses 30, the previous bar should be lower than 29 (so the bar crosses from bottom to top). In the tester I set a short time frame on an hourly timeframe to count the number of signals manually and compare it with the EA's readings. I should get 6 signals, but the EA just displays a wall of text with buy signals, and ideally there should only be 6.


Here is the code of Expert Advisor, may be someone can tell me what I am doing wrong?


// Значения торговли
extern double TP = 100;
extern double Lots = 0.1;
extern double SL = 50;
// Значения стохастика
extern int Dperiod = 24;
extern int Kperiod = 3;
extern int Slowing = 6;
extern int St_buy = 30;
extern int St_sell = 70;
int signal;
int ticket;



int Stoch(int st_bars = 0, int st_type = 0){  // 1 параметр - бары, 2 параметр - тип линии.

   int st_result;
   
   if (st_type == 0 || st_type == 1 && st_bars >= 0){
      st_result = iStochastic(NULL,0,Dperiod,Kperiod,Slowing,MODE_SMA,0,st_type,st_bars);
      if (st_result > -1) return(st_result);
   }
   else return(-1);
   
   return(0);
}

int Criterion() // 10 - open buy, 11 - close buy, 20 - open sell, 21 - close sell.
{
   int St_M, St_S;
   St_M = Stoch();
   St_S = Stoch(0,1);
  
   if (St_M >= St_buy && Stoch(1,0) < (St_buy-1)) return(10);
   
   return(0);
}

int start()
{
   if (Criterion() == 10 && AccountFreeMargin() > Lots*5000){
      
    ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Bid - SL * Point, Ask + TP * Point, "My order #", 16384, 0, Green);
   }
   return(0);
}
 
trader_john:

Can you tell me what could be causing this glitch?

It works, works, everything is fine, then suddenly, all of a sudden :-(

And, not just dots are drawn where they should not be, but the data window also shows incorrect data (pertinent to the location of the dots)

(The indicator shows extrema, I wrote it myself )

After "rewinding" of a timeframe everything becomes normal

Maybe you can advise which way to "dig". Or maybe there already is a topic on the forum.

Thanks in advance!


Everything before you has already been stolen - it's like MasterForex version 5... There is also version 4, but I can't find it yet, if you need it I will find it.