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

 

Good afternoon. Please advise how to implement the following:

I have an open Buy position. The next candle went strongly downwards and triggered a stop. But as the movement was sharp and the signals still show Buy, a long position will be opened again on the next tick. What lines should be introduced into the code to delay the position opening until the next candle is closed, for example?

And the second question. Can we specify the upward direction of stochastic lines in the code as one of the rules?

Thank you very much.

 
Sorry for trolling! Where's the error, guys? A signal is triggered, after 2 bars passes if it meets the condition, then we open a trade.
if (bay == true)   datetime T=Time[0] //сработал сигнал на покупку запоминаем время  бара

if(iBarShift(NULL,0,T)==2) //по времени, сигнал был на 2 баре
   {   
  if (Open[1]<Close[1] && Open[2]<Close[2] )   //и эти бары бичьи 
     { 
    // что-то делаем
     }
   }
 
Top2n:
Sorry for trolling! Where's the error, guys? The signal is triggered, after 2 bars passes if it meets the condition, then we open a trade.

static int T=0;
if (bay == true && T==0)   T=Time[0] //сработал сигнал на покупку запоминаем время  бара

if(iBarShift(NULL,0,T)==2) //по времени, сигнал был на 2 баре
   {   
  if (Open[1]<Close[1] && Open[2]<Close[2] )   //и эти бары бичьи 
     { 
     T=0;
    // что-то делаем
     }
   }
Although the most unfortunate option. We should check the signal itself on the right bar
 
Vinin:

The most unfortunate option, though. You need to check the signal itself on the right bar

How do you do that?
 
Top2n:

How's that?

How do you check the signal? Exactly the same way, but on different bars
 
Top2n:

How do you do it?

Everything has to be squeezed out of you one drop at a time.

if (StochM < St_min && StochS < St_min)
bay_min = true;

Do this check for bars 2 more.

 
Oooh, right, thank you very much!)
 
r772ra:

Try it this way:


Thank you!!! That's just what you need. The first brick is laid.

But I thought, I don't need to change Startprice value every minute and check the condition.

if  (Low[4]< MA4 && MA4 < High[4])            //условия если 4-я свеча лежит в скользящей  

I need to check the condition at the close of the candle timeframe, and if it is consistent with the value of the variable Startprice posted value of the last candle.

So, we have to check it on bar close. I do not know how to do it. I will not be able to handle it myself if you just add 0+0).

If it bothers me that the sliding indicator has been applied to close prices, we may change it to open prices as well. It makes no difference to me.

Bug remains, closing price does not correspond to the value of the object

Please help me with code or thinking. If it's the latter, I'll have to work on it for a couple of months).


 
supernyb:

bool NewBar()
{static datetime newbar;
bool res=false;
if(newbar==0)newbar=Time[0];
if(newbar!=Time[0]){res=true;newbar=Time[0];}
return(res);
}

New bar presence .

 
I deleted a data folder about 3-4 months ago. The recycle bin was emptied. Now I need one file from there. Can anyone suggest a program to recover deleted files?
Reason: