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

 
Summus_Digitus:
Hello all. This is a serious and urgent matter and I've looked all over the Internet, as they say... I decided to use MT4 for a long time, I've been using it for 3 days. I tried to use it for a while and it seemed to me that it was for the first time and I didn't understand what was going on. I thought, it's nothing serious, but all of a sudden I go to MT and I see 4 H4 charts with a new system and I see the wrong price, I compare it with the StartFX 2, I open time frame H1 and D1 and I wait... I have been waiting for an hour and it will update year by year, but it won't do that. "Well, reinstall it and that's it" - you say, and I'll tell you "Fuck it". "So download an indicator of some software update from who knows what site" - you ask and I'll tell you "Fuck it twice". I really want to keep making money and strangle the computer help with 1 and then we'll see :-)

Sobbing! Honestly - I read it and a stinging tear rolled down my face shaking with laughter...
 
VladTch:

Good day to all!

My question seems to be simple, but I dug through all the articles, but could not find an answer - how does the return(-1) operator work? Where does it pass control to? In this code, for instance:

else return(0);

Everything seems clear with zero in brackets and without brackets. But what about (-1)?

Thank you for replying. :)

Special functions are general functions. They can be called like user-defined functions. But there is one peculiarity. During system call parameters and return value are not passed.

 
Summus_Digitus:
Hello all. This is a serious and urgent matter and I've looked all over the Internet, as they say... I decided to use MT4 for a long time, I've been using it for 3 days. I tried to use it for a while and it seemed to me that it was for the first time and I didn't understand what was going on. I thought, it's nothing serious, but all of a sudden I go to MT and I see 4 H4 charts with a new system and I see the wrong price, I compare it with the StartFX 2, I open time frame H1 and D1 and I wait... I have been waiting for an hour and it will update year by year, but it won't do that. "Well, reinstall it and that's it" - you say, and I'll tell you "Fuck it". "So download an indicator of some software update from who knows what site" - you ask and I'll tell you "Fuck it twice". I really want to keep making money and strangle the computer help with 1 and then we'll see :-)

To the Annals!!!
 

Why can't I paint a number?

 #property indicator_chart_window
void start()
   {
string spred=DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD), 0);
   string lot=AccountFreeMargin()/(Bid)*0.002;
   string lots=StringSubstr(lot, 4, 1);
 
SetLabel("ЧИСЛО",   lots , ColorOnSign(lots), 5, 7, 1);}
  
   color ColorOnSign(double nu){
      color lcColor=Navy;
         if (nu<4) lcColor=Green;
         if (nu>6) lcColor=Red;
      return(lcColor);}
     
   void SetLabel(string nm, string tx, color cl, int xd, int yd, int cr=0, int fs=9) {
      if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_LABEL, 0, 0,0);
         ObjectSetText(nm, tx, fs);
         ObjectSet(nm, OBJPROP_COLOR    , cl);
         ObjectSet(nm, OBJPROP_XDISTANCE, xd);
         ObjectSet(nm, OBJPROP_YDISTANCE, yd);
         ObjectSet(nm, OBJPROP_CORNER   , cr);
         ObjectSet(nm, OBJPROP_FONTSIZE , 18);
      return(0);}

Why can't I paint a number?

 

That's weird. I thought there was a question.

It's compiling!

 
Elektronik:

Why can't I paint a number?

 #property indicator_chart_window
void start()
   {
string spred=DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD), 0);
   string lot=AccountFreeMargin()/(Bid)*0.002;
   string lots=StringSubstr(lot, 4, 1);
 
SetLabel("ЧИСЛО",   lots , ColorOnSign(lots), 5, 7, 1);}
  
   color ColorOnSign(double nu){
      color lcColor=Navy;
         if (nu<4) lcColor=Green;
         if (nu>6) lcColor=Red;
      return(lcColor);}
     
   void SetLabel(string nm, string tx, color cl, int xd, int yd, int cr=0, int fs=9) {
      if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_LABEL, 0, 0,0);
         ObjectSetText(nm, tx, fs);
         ObjectSet(nm, OBJPROP_COLOR    , cl);
         ObjectSet(nm, OBJPROP_XDISTANCE, xd);
         ObjectSet(nm, OBJPROP_YDISTANCE, yd);
         ObjectSet(nm, OBJPROP_CORNER   , cr);
         ObjectSet(nm, OBJPROP_FONTSIZE , 18);
      return(0);}

Why can't I paint a number?

You painted it, but to change the colour you have to create another object with the same colour! And change the objects, then the colour will visually change! That's what I understand! Or maybe there's a different opinion? I myself have only changed colours with Mashka in this way.
 

I think it's all about the number.

lots=StringSubstr(lot, 4, 1); 

maybe the software understands it as a single digit.

 
Elektronik:

That's weird. I thought there was a question.

It's compiling!

Yeah, I wanted to add to it and accidentally deleted it. Didn't want to restore it.

You have to change the colour with this:

ObjectSet(nm, OBJPROP_COLOR, cl);

Your code doesn't show where you change the colour.

============

I figured out where...

This is how you do it:

   void SetLabel(string nm, string tx, color cl, int xd, int yd, int cr=0, int fs=9)
    {
     ObjectCreate(nm, OBJ_LABEL, 0, 0,0);
     ObjectSetText(nm, tx, fs);
     ObjectSet(nm, OBJPROP_COLOR    , cl);
     ObjectSet(nm, OBJPROP_XDISTANCE, xd);
     ObjectSet(nm, OBJPROP_YDISTANCE, yd);
     ObjectSet(nm, OBJPROP_CORNER   , cr);
     ObjectSet(nm, OBJPROP_FONTSIZE , 18);
    }

Don't be afraid to re-create the object. It's optimized. If an object is created, it only changes the properties that change. It will not be recreated.

Please put curly brackets on one level, otherwise you won't understand what is written where blocks start and end.

There must be problems with the ColorOnSign() parameter. The parameter is double and you insert string.

SetLabel("ЧИСЛО", lots, ColorOnSign(StrToDouble(lots)), 5, 7, 1);

Or

color ColorOnSign(string sLots)
 {
  double nu = StrToDouble(sLots);
  color lcColor=Navy;
  if (nu<4) lcColor=Green;
  if (nu>6) lcColor=Red;
  return(lcColor);
 }
 

Good afternoon, help me out and if you can give me a hint on the code.

I have the following trawl in owl ->

        for ( int v = OrdersTotal() - 1; v >= 0; v -- ){       
                if (OrderSelect(v, SELECT_BY_POS, MODE_TRADES)){           
                        if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic){ 
                                //+=================================================================================+
                                ///+================================Обычный трал ====================================+
                                if (TralSimple){
                                        if(OrderType() == OP_SELL){
                                                if((OrderOpenPrice()-Ask) > (Point*TrailingStop)){ 
                                                        if((OrderStopLoss() > (Ask+Point*TrailingStop)) || (OrderStopLoss()==0)){
                                                                OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                                                        }
                                                }
                                        }
                                        //+=================================================================================+
                                        if(OrderType() == OP_BUY){
                                                if((Bid-OrderOpenPrice()) > (Point*TrailingStop)){
                                                        if(OrderStopLoss() < Bid-Point*TrailingStop || (OrderStopLoss()==0)){
                                                                OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Blue);  
                                                        }
                                                }
                                        }
                                }                                  
--------------------------------------------

Now the trawl moves a stop after every positive tick. I want to do the following:

the first pass - at a positive tick the trawl will move the stop by 1 point and increase the step up.

Second pass - let's take a variable x which will be incremented by 1 each time we make a certain step (5). And with each pass (step)*x

etc.

The question is how to screw in this step with increasing multiplier. In case of several positions this multiplier should be different for each position

 
berezhnuy:

Good afternoon, help me out and if you can give me a hint on the code.

I have the following trawl in owl ->

Now the trawl moves a stop after every positive tick. I want to do the following:

first pass - at a positive tick the trawl will move the stop by 1 point, and by how much the pair has gone up.

Second pass - take a variable x which will be increased by 1 at every pass.

etc.

The question is how to add a step with increasing multiplier. And in case of several positions, this multiplier should be different for each position


You do something like parabolic, calculation is relative to the base point - price and opening time