Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 836

 
Kirill875:

Is that what you meant:

Also this Buff8[i]=iMA(NULL,60,Period1,sh 0,MODE_SMA,PRICE_CLOSE,sh);

And use the code paste.

 
Roman_Bryansk:

Thanks for the tip. That's what I thought the message was like, it doesn't look good. Good to know. Correcting the message.

There are magic "delete" and "edit" options at the bottom-right under your posts, no need to write the same thing in a new post, you just had to fix it there ;)
 
evillive:
For code there is a button at the top of the message editing panel or the Ctrl+Alt+M combination, the code becomes nice and readable. And about losses, f-function SetIndexStyle() has a colour parameter, use it, feel free.

If you don't mind, can you give me some more details? I just need the colour and width settings to go like this:

# colour width style

0. Black 0 0

1. black 0 0

2. red 2 0

3. Green 2 0

The width always disappears, i.e. it's as if it always reverts to the default setting.

Don't judge, I just don't seem to have what you have. Also when compiling 2 such messages: not all control paths return a value SimpleBars.mq4 115 1.

 
Understood. My apologies. I made a mess of things.
 
Roman_Bryansk:

If you don't mind, can you give me some more details? I just need the colour and width settings to go like this:

# colour width style

0. Black 0 0

..

always disappears width, i.e. it's like it always goes back to the default settings.

Don't judge too harshly, I just don't seem to have what you have. Also at compilation 2 such messages: not all control paths return a value SimpleBars.mq4 115 1.


void  SetIndexStyle(
   int     index,       // номер линии
   int     type,        // тип
   int     style=EMPTY, // стиль линии
   int     width=EMPTY, // ширина линии
   color   clr=clrNONE  // цвет
   );

That is for first buffer in your case:

SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY,width,Red);

If settings are not saved, you have insufficient permissions to write to terminal data directory. This happens when you install it on the system partition and run it in normal mode. Try to run terminal in /portable mode (key is written in terminal startup shortcut).

And I always recommended and will continue to recommend to all users to install all the programs they can on a non-system partition.

 
Простите меня за наглость)
 
evillive:


That is, for the first buffer in your case:

If the settings are not saved, it is possible that you do not have sufficient write permissions to the terminal's data directory. This happens when you install it to the system partition and run it in normal mode. Try to run terminal in /portable mode (key is written in terminal startup shortcut).

And I always recommended and will continue to recommend to all users to install all the programs they can on a non-system partition.

You are a wizard ))Replaced it withEMPTY and all is ok with the two indicators. Thank you very much. Regarding "/portable": when I write in the settings of the object string it says wrong path.
 
Roman_Bryansk:
You're a magician ))Replaced it withEMPTY and all is well with the two indicators. Thank you very much. Regarding "/portable": When I write in the settings of the object string does not write the correct path.
I just need to put the key behind the quotes.
 
Kirill875:
The terminal hangs after compiling. Could you show me an example of where to put in.

Here is

Files:
testmtf.mq4  4 kb
 

MQL4

The idea is simple:

We set BuyLimit or SellLimit and expected TakeProfit.

The task of the Expert Advisor is to set StopLoss for all orders in such a way that the expected loss is 10 times less than the expected profit.

Everything works, the Expert Advisor constantly monitors the orders and if a new order appears, or if I have changed the open/stake profit price in any order, it immediately adjusts the StopLoss to the specified parameters.

The weirdness started when I decided that the EA should not correct the stoplosses of those orders where those stoplosses have been set to "breakeven".

I added a simple condition before modifying an order (it is commented in the code below) and the Expert Advisor stopped working. It stopped modifying any order at all.

I have experimented but I still do not understand where my mistake is.

One more strange thing:

If we replace "else" with a direct condition "if (OrderType()==OP_SELL)". - the Expert Advisor stops working as well.

I could not find the reason for this either.

int i=0;

void start()
{
   i=OrdersTotal();
   while (i>0)
   {
      i=i-1;
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if (MathAbs(OrderTakeProfit()-OrderOpenPrice())!=MathAbs(OrderOpenPrice()-OrderStopLoss())*10)
      {
         if (OrderType()==OP_BUY)
         {
            //if (OrderOpenPrice()>OrderStopLoss())
            OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-(OrderTakeProfit()-OrderOpenPrice())/10,OrderTakeProfit(),0);
         }
         else 
         //if (OrderType()==OP_SELL)
         {
            //if (OrderOpenPrice()<OrderStopLoss())
            OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+(OrderOpenPrice()-OrderTakeProfit())/10,OrderTakeProfit(),0);
         }
      }
   }
}