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

 
MaxZ:

Replace OP_SELLSTOP with OP_SELLLIMIT, OP_BUYSTOP with OP_BUYLIMIT.

Also, there is no point in using it twice:

You have an order already selected and you select it again.

it does not work!

void otlogka (int order)
{
int a, k=OrdersTotal();

for (a=k-1; a>=0; a--) {
if (OrderSelect(a, SELECT_BY_POS, MODE_TRADES)) {
if (OrderType()==OP_BUY) {
if ///// it might be better to specify (Bid-OrderOpenPrice())>20
(OrderProfit()+OrderCommission()+OrderSwap()<0) {
order=OrderSend(Symbol(),OP_SELLLIMIT,0.02,NormalizeDouble(Ask,Digits)+15*Point,1,0,12, "Otlogka",mn,5,0);
}}}}
if (OrderType()==OP_SELL){
if (OrderProfit()+OrderCommission()+OrderSwap()<0) {
order=OrderSend(Symbol(),OP_BUYLIMIT,0.02,NormalizeDouble(Ask,Digits)-15*Point,1,0,12, "Otlogka",mn,5,0);
}}}
 
MaxZ:

o.O

Where was RefreshRates() needed?

Or did you write your own Refrashrates() function? :DD


RefreshRates() is needed at the point where prices are accessed.
 
smartemiy:

What is the number "12" in the OrderSend function? :(

And you misunderstood me about the selection of orders... It should be like this:

int a, k = OrdersTotal();
for (a = k-1; a >= 0; a--)
   if (OrderSelect(a, SELECT_BY_POS, MODE_TRADES))
   {
      if (OrderType()==OP_BUY )
      {
// ......................
      }
      if (OrderType()==OP_SELL)
      {
// ......................
      }
   }
 
PapaYozh:

RefreshRates() is needed where prices are accessed.
How about predefined variables and time-series arrays?
 
MaxZ:
Or maybe to predefined variables and time-series arrays?

Whether to predefined variables or via MarketInfo
 
PapaYozh:

Whether to the predefined ones or via MarketInfo

And I tell you no: https://www.mql5.com/ru/forum/102562.

 
MaxZ:

And I'm telling you no: https://www.mql5.com/ru/forum/102562


And indeed.
 
PapaYozh:

And indeed.

Yeah, I was surprised myself! :)) I stumbled on this forum branch accidentally at night and immediately noted this fact to myself...

That's why I wondered very much where I should have inserted Refrashrates() to make my code work and stop getting error 129.

 
As I understood, all prices were taken from marketinfo and normalised, but the orders did not go through. It was as if the order line was missing. I decided to find out what kind of error he was encountering. Alert was swearing about wrong prices every time, even though I was sure the prices were normalised. Asked the question here. And I added refreshrates at the beginning of the start function, before the tool cycle.
 
Are there any people who will write an EA for providing a trading system, well I don't have an extra 50-100 quid! The trading system really works and is very simple!!! But based on MASD and muwings, it also takes into account one factor... It works on dolar/lb, euro/dollar, i cant test it on others.... On this one on cents I have been trading successfully for 3 months now but I miss about 70 percent of entry points!!! Help...
Reason: