[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 742

 
artmedia70:

I don't want to deal with your code (evil, but honest :)). Tell me exactly what you want to get in the end and I'll write you the function you need. Honestly - it will be easier for me. I should sort out my own code... :)

... Or go to bed, go to sleep, and the next day all your puzzles will come together... :) That's what I do when I don't get it... By the way, off to bed - it's half past 5am already...


After the order has been set, the variables that were the criteria for the order should be set to "0" again,

 
Who knows. How can I get the ratio of indicator movement (on its scale), for example RSI, with the ratio of the passed currency ticks? For example, if RSI went from 0 to 50, how many ticks does it equal?
 
Infinity:
Who knows. How can I get the ratio of indicator movement (on its scale), for example RSI, with the ratio of the passed ticks of the currency? For example, if RSI went from 0 to 50 - how many points will it be equal to?

Catch the last value of the RSI indicator on a zero candle. We wait for the next tick. The tick has come. Let price has ticked exactly 1 point. See how much the RSI has changed. That's it - the odds are in our pocket.
 
drknn:

Catch the last RSI indicator value on the zero candle. We wait for the next tick. The tick is here. Let's assume that price has ticked exactly 1 point. See how much the RSI has changed. That's it - the coefficient is in our pocket.

But then how is it possible, for example, I have caught the coefficient of 1 point, RSI has passed on its scale of 50, it turns out that it has passed 50 points, but in fact it was a flat. And the candle has 2 points. So how to determine in this case
 
cyclik33:

Dear Anatoly. Thank you very much for this code. Another question, how to make it work all the time but make only 1 deal per bar?

Boris, well, it's even simpler than that. You drop this line:

datetime new;

At the very top of the code (to be separately, not in any function).
And then, in those places where there is a call of the OrderSend(...) function, just enclose it in an additional hug of the if operator

if(new != Time[0]){
   new = Time[0];
   // здесь функция OrderSend(...);
}

Now, before opening another position, it will check if the current bar contains any trades or not. If there were, the current bar will be stored in the variable new and if the current bar is the same as the one stored, the trade will not be opened. Accordingly if the bar is new, then its opening time will not coincide with the data of the variable new, the deal will be opened and the variable new will get a new value.

I do not know exactly the architecture of your Expert Advisor, but this method should work in most cases.

 
FoxUA:

After the order has been set, the variables that were the criteria for placing the order should be set to "0" again,


I tried to compile your code, it generated errors.
You have to use variables that were used as a criterion for placing an order in two methods(start() and NewOrder1()), declare them outside of all functions:

bool b,s, //соответственно бай или селл  
bs,// если закрытие по стоплоссу ордера бай
ss,// если закрытие по стоплоссу ордера sell
bt,
st;//      то же по ТП
double bl,sl; // лоты соответсвенно для бай и селл
then in the for loop
for(int cnt=OrdersHistoryTotal();cnt>0;cnt--)
     {
OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
{if(OrderMagicNumber()== mag &&
OrderSymbol()==Symbol()) 
{ if (OrderType() == OP_BUY )  {b=1; if (OrderClosePrice()==OrderTakeProfit()) bt=1; if (OrderClosePrice()==OrderStopLoss()) bs=1; bl=OrderLots()*10; break;}
if (OrderType() == OP_SELL)  {s=1; if (OrderClosePrice()==OrderTakeProfit()) st=1; if (OrderClosePrice()==OrderStopLoss()) ss=1; sl=OrderLots()*10; break;}
            }
         }
      }


}//end

They should be assigned the necessary values, and after the order is successfully opened in the NewOrder1() function, they should be reset to zero there as well.

int NewOrder1(int Cmd,double Lot)
{double TP=0; //тейкпрофит
double SL=0; //стоплосс
double PR=0; //Цена
double LT=0; //Лот
while(!IsTradeAllowed()) Sleep(100);
if(Cmd==OP_BUYLIMIT)
   {PR=Ask-Point*h;
    if(TakeProfit>0) TP=PR+TakeProfit*Point;
    if(StopLoss>0) SL=PR-StopLoss*Point;
    if(Lot>0) LT=3*Lot;}
int tic1=OrderSend(Symbol(),Cmd,LT,PR,3,SL,TP,0,mag,0,CLR_NONE);
//-----------
if(tic1<0){
   Print(GetLastError());
}else{
b=0;
s=0; 
bs=0;
ss=0;
bt=0;
st=0;
bl=0;
sl=0;
}
//-----------
return(0);}

Something like this.

 
Infinity:

Who knows. How can you get the ratio of the indicator movement (on its scale) for example RSI, with the ratio of the ticks crossed by the currency? To clarify, if RSI went for example from 0 to 50 - how many ticks it will be equal.

I once had a similar goal, so I wrote a "ruler" like this, maybe it would work for you too.

//+------------------------------------------------------------------+
int get_pips_RSI_path(int home_shift, int end_shift){
   double home_index, end_index;
   double home_price, end_price;
   int path;
   
   home_index = iRSI(NULL,0,14,PRICE_CLOSE,home_shift);
   home_price = Close[home_shift];
   end_index = iRSI(NULL,0,14,PRICE_CLOSE,end_shift);
   end_price = Close[end_shift];
   
   if(end_price > home_price)path = (end_price - home_price)/Point; else path = (home_price - end_price)/Point;
   
   Alert("Между значениями RSI ", home_index, " и ", end_index, " было пройденно ", path, " пунктов.");
   return(path);
}
//+------------------------------------------------------------------+

As parameters you send shifts of bars with desired RSI values, in response you get the distance between them in pips.

 
ToLik_SRGV:

I once had a similar goal and wrote a "ruler" like this, maybe it would work for you too.

As parameters you send the shifts of bars where the desired RSI values are located, in response you get the distance between them in pips.


Thanks, I will check it tonight

I have a strong feeling that the test on the history of the Expert Advisor will not give a good result because of the incompleteness of quotes history. I understand that the quotes history is formed by archiving the current market (candlestick quotes), but how can you rely on the result, if the real quotes (at least in my case) are flying through, sometimes for 40 minutes just no candles, the chart stands, then it flies all the same candle.

 
ToLik_SRGV:

Maybe you just could not find a profitable combination of parameters, try unchecking the "Ignore useless results" option.

And don't forget to check the checkboxes in the Expert Advisor settings for the parameters you want to optimize, as well as set the step and optimization limits.

Thank you, that's right, "Skip useless results" is checked.
 
artmedia70:


Friends! I cannot figure out how to get rid of unnecessary signals that appear when the trend line is reversed. The trend line (descending in the example) is plotted from the largest extremum to the smallest extremum, found within a specified interval of bars. The problem is that as soon as a new lowest extremum appears, the trend line jumps to that extremum (it is designed that way).

But, also on the first bar the trend line builds levels with the value of the trend line, the crossing of which by the indicator line gives a signal. If the indicator line on the first bar is below this level and on the second bar it is above this level, then we have a top-down crossover.

So... When the trend line jumps to a new lowest extremum, a situation arises where the indicator line on the second bar is above the trend line and below the plotted level and on the first bar, i.e. an unnecessary sell signal (in this case):


We can see in the picture that the trend has moved to a new extreme (location is marked with a down arrow) and the price level of the new trend on the first bar (horizontal red dash line)
became lower than the AD line on the second bar and the AD line on the first bar is lower than the price level...
Accordingly, by moving the trend line to a lower extremum an unwanted signal was simulated... The same unnecessary signal occurred earlier -
I marked it with a vertical light blue line...

Hence the question - how to avoid this situation? I'm exhausted trying to think of something...
Any thoughts? Thanks... :)



I understand that a trade signal should occur when the indicator line crosses the trend line, and not vice versa, and you have it both ways. Keep the previous values of the trend line position in static variables and if they haven't changed, check for a crossover, if the trend line has changed position - reset...

Reason: