[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 466

 

Question for expert programmers!

How do I set a StopLoss?

newstop - the new price detected by the indicator line, at this price I want to set a stop loss

For example newstop = 1.5005, but the price Bid is at a level = 1.5000, and the broker stoploop at 10 points, respectively, that I can not set the stoploss at this level, how to prescribe it correctly to avoid errors from the stoploop?


(newstop>MarketInfo(Symbol(),MODE_STOPLEVEL))


Thank you.

 

double op=NP(MathMax(Bid-SL*Point, Bid-StopLvl))


NP - price normalization.

 
sergeev >>:

double op=NP(MathMax(Bid-SL*Point, Bid-StopLvl))


NP - нормализация цены.

Thanks, but what about multiplying by Point?

I didn't show all the code, that's probably why I didn't quite understand my question, here's a piece of code.

Will the logic of what is written below work?

if ((OrderStopLoss()==0)&&( newstop>MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)) // если стоплосс не определен, то тралим в любом случае
     OrderModify( ticket,OrderOpenPrice(), newstop,OrderTakeProfit(),OrderExpiration());  
 

Or do I have to do this first, for example, for bai?

   int mi = MarketInfo(Symbol(),MODE_STOPLEVEL);
   double m = mi*Point;
   double mi1 = NormalizeDouble ( Вid - m,Digits); 

if ((OrderStopLoss()==0)&&( newstop< mi1)) // если стоплосс не определен, то тралим в любом случае
         OrderModify( ticket,OrderOpenPrice(), newstop,OrderTakeProfit(),OrderExpiration());  
 
Gun писал(а) >>

Or should I do this first, for example for buy?

The order type has to be taken into account when checking the condition. You can do it like this:

if (OrderStopLoss()==0 && OrderType()==0 && newstop<=Ask-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point) //если buy

OrderModify( ticket,OrderOpenPrice(), newstop,OrderTakeProfit(),OrderExpiration());

else

if (OrderStopLoss()==0 && OrderType()==1 && newstop>=Bid+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point) //если sell

OrderModify( ticket,OrderOpenPrice(), newstop,OrderTakeProfit(),OrderExpiration()); 
 
Question for programmers. The search hasn't yielded anything yet. How, in the trading robot to set (where to find a code block / someone did this issue) skipping stakes, that is, the robot trades starting from the second bid after a loss-making, because the transaction is virtual, and when found triggered stoploss in one robot gnanchinaet trade already money, then worked out a given number of rates, but again begins to trade in the virtual (skipping rates) and again waiting for triggered stoploss, again through one starts working using in betting depot means.
 
kraizislot писал(а) >>
Question for programmers. The search hasn't yielded anything yet. How, in a trading robot to set (where to find a block of code / someone did this issue) skipping stakes, that is, the robot trades starting with the second bid after a loss-making, because the transactions take place virtually, and when found triggered stoploss in one robot gnachinaet trade already money, then worked out a given number of rates, again begins to trade with non-money but virtually (skipping rates) and again waiting triggered stoploss, again through one starts working using in betting depot means.

There was an article like this.

 
I've got articles on skipping bets, but there's no code to *make* the robot skip bets, or I couldn't find it (I opened the attached archives). There is a robot giving a hundred bets a year with one or two losing ones, if I wait for them and then enter the market, but do it automatically, it's another martingale. If you wait for them and then enter the market automatically, it is another martingale. I thought the subject is solved, but I cannot find any code.
 
kraizislot писал(а) >>
The articles on skipping bets do exist, but the code itself to *make* the robot skip bets is absent, or not found (I opened the attached archives). There is a robot that makes one or two losing bets per year, if I wait for them and then enter the market, but do it automatically, it's another martingale. If you wait for them and then enter the market automatically, it is another martingale. I thought the subject is solved, but I cannot find any code.

A virtual trading module needs to be made. The code to implement this approach is there. You just need to adapt it to your own needs.

 
Ugh! Where can I find it, please?