need advice from a trawl pro that controls two positions independently of each other, how can it be implemented? - page 8

 
charony:

i feel sorry for you.

Likewise )

ZS: seven pages of trawl, that's the way to do it.)

 
Yes cut it twice and it's still short
 

)))).

ZS: there is no test run in the tester.

1. Put the Expert Advisor on the chart with open positions

2. The Expert Advisor marks each position with its own line.

3. In the line properties (the line "Description"), set the required line for the required order in points (don't change the line name, it is equal to the order ticket)

4. Observe how the trawl works)))

5. Do not ask how we may deal with what we cannot deal with.

Files:
 
//+-----------------------------trailingstop----------------------------------------------
for(int i=OrdersTotal()-1;i>=0;i--)
   {
      if(OrderSelect(i,SELECT_BY_POS)==true)
      {
         {
            int cmd=OrderType();
            if(cmd==OP_BUY)
            {
               if(ObjectFind(DoubleToStr(OrderTicket(),0))<0)
               {
                  ObjectCreateTrend(false,DoubleToStr(OrderTicket(),0),OBJ_HLINE,0,0,OrderOpenPrice(),0,0,Blue,0,0,"",0);
               }
               else
               {
                  if(ObjectDescription(DoubleToStr(OrderTicket(),0))!="30")//if(TrailingStop>0)  
                  {                 
                     if(Bid-OrderOpenPrice()>Point*StrToDouble(ObjectDescription(DoubleToStr(OrderTicket(),0))))
                     {
                        if(OrderStopLoss()<Bid-Point*StrToDouble(ObjectDescription(DoubleToStr(OrderTicket(),0))))
                        {
                           OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*StrToDouble(ObjectDescription(DoubleToStr(OrderTicket(),0))),OrderTakeProfit(),0,Green);
                        }
                     }
                  }
               }
            }
            if(cmd==OP_SELL)
            {
               if(ObjectFind(DoubleToStr(OrderTicket(),0))<0)
               {
                  ObjectCreateTrend(false,DoubleToStr(OrderTicket(),0),OBJ_HLINE,0,0,OrderOpenPrice(),0,0,Red,0,0,"",0);
               }
               else
               {
                  if(ObjectDescription(DoubleToStr(OrderTicket(),0))!="30")//TrailingStop>0)  
                  {                 
                     if((OrderOpenPrice()-Ask)>(Point*StrToDouble(ObjectDescription(DoubleToStr(OrderTicket(),0)))))
                     {
                        if((OrderStopLoss()>(Ask+Point*StrToDouble(ObjectDescription(DoubleToStr(OrderTicket(),0))))) || (OrderStopLoss()==0))
                        {
                           OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*StrToDouble(ObjectDescription(DoubleToStr(OrderTicket(),0))),OrderTakeProfit(),0,Red);
                        }
                     }
                  }
               }
            }
         }
      }
   }
   return(0);
  }
//+------------------------------------------------------------------+
void ObjectCreateTrend(bool RayLines,string iObjectName,int Type,int iWindow,int X1Time,double Y1Price,int X2Time,double Y2Price,color iColor,int Code,int sound,string coment,int angle)
{
        if (ObjectFind(iObjectName)<0) {
                ObjectCreate(iObjectName,Type,iWindow,0,0);
                ObjectSet(iObjectName,OBJPROP_COLOR,iColor);
         ObjectSet(iObjectName,OBJPROP_RAY,RayLines);
        }
        if (X1Time!=0)
           ObjectSet(iObjectName,OBJPROP_TIME1,X1Time);
        ObjectSet(iObjectName,OBJPROP_PRICE1,Y1Price);
        if (X2Time!=0)
           ObjectSet(iObjectName,OBJPROP_TIME2,X2Time);
        if (Y2Price!=0)
           ObjectSet(iObjectName,OBJPROP_PRICE2,Y2Price);
        if (Code!=0)
           ObjectSet(iObjectName,OBJPROP_ARROWCODE,Code);
        if (coment!="")
           ObjectSetText(iObjectName,coment,10,"Times New Roman",iColor);
        if (angle!=0)
           ObjectSet(iObjectName,OBJPROP_ANGLE,angle);
        //ObjectSet(iObjectName,OBJPROP_FIBOLEVELS,7);
        //ObjectSet(iObjectName,OBJPROP_FIRSTLEVEL+0,0);
        //ObjectSet(iObjectName,OBJPROP_FIRSTLEVEL+1,0.5);
        //ObjectSet(iObjectName,OBJPROP_FIRSTLEVEL+2,1);
}


 //-------------------------------------tral-------------------------------------------------
  
//+-----------------------------trailingstop end----------------------------------------------+
   
такое вставил
 


got this
 

you put in shit - you get shit, then when you create an object, make the description "30" instead of checking for a description equal to "30".

ZS: could have asked how to make object description equal to "30" at once.

 
if(ObjectDescription(DoubleToStr(OrderTicket(),0))!="30")/

Is this what you think replacing "" with "30" should have resulted in?

ZS: this line prevented the trawl from starting when the description was empty.

 
sanyooooook:

Is this what you think replacing "" with "30" should have resulted in?

ZS: this line prevented the trawl from starting when the description was empty.

You Udmurts surely don't know the old Kholya proverb - "Don't waste a kume's strength..." :))
 
granit77:
You Udmurts surely don't know the old Khohlian proverb - "Don't waste a kume's strength..." :))
I've heard it for the first time, it's probably "like a pea against the wall", or "like a fish against ice", or "to teach fools is like to heal the dead" )
 
sanyooooook:

If you put in shit, you get shit, so make the description "30" when creating the object instead of checking for a description equal to "30".

ZS: could ask how to make the description of the object immediately equal to "30".


I'm afraid to ask, you're such an angry guy

In theProperties of the line (line "Description") in the paragraphs set the desired trawl

ObjectDescription is a property, put it there

Where do you want to insert it? 30 points trawl