TrendMeLeaveMe_Gold_mod

Author: Copyright � 2007,Eng Waddah Attar, mod.Dimicr
Profit factor:
0.41
10 Views
0 Downloads
0 Favorites
TrendMeLeaveMe_Gold_mod
//+------------------------------------------------------------------+
//|                                          TrendMeLeaveMe_Gold.mq4 |
//|                              Copyright © 2007, Eng. Waddah Attar |
//|                                                        mod.Dimicr|
//|                                          waddahattar@hotmail.com |
//+------------------------------------------------------------------+



#property copyright "Copyright © 2007,Eng Waddah Attar, mod.Dimicr"
#property link      "www.metaforex.net"
//----
extern bool   AutoClose = true;
extern string BuyStop_Trend_Info = "_______________________";
extern string BuyStop_TrendName = "STL2";
extern int    BuyStop_TakeProfit = 50;
extern int    BuyStop_StopLoss = 30;
extern int    BuyStop_StepActive = 10;
extern int    BuyStop_StepPrepare = 50;

extern string BuyLimit_Trend_Info = "_______________________";
extern string BuyLimit_TrendName = "buylimit";
extern int    BuyLimit_TakeProfit = 50;
extern int    BuyLimit_StopLoss = 30;
extern int    BuyLimit_StepActive = 5;
extern int    BuyLimit_StepPrepare = 50;

extern string SellStop_Trend_Info = "_______________________";
extern string SellStop_TrendName = "STL1";
extern int    SellStop_TakeProfit = 50;
extern int    SellStop_StopLoss = 30;
extern int    SellStop_StepActive = 10;
extern int    SellStop_StepPrepare = 50;

extern string SellLimit_Trend_Info = "_______________________";
extern string SellLimit_TrendName = "selllimit";
extern int    SellLimit_TakeProfit = 50;
extern int    SellLimit_StopLoss = 30;
extern int    SellLimit_StepActive = 5;
extern int    SellLimit_StepPrepare = 50;

extern string  ParamTrail = " --- Trailing Stop Parameters ---";
extern bool    UseTrailingStop = 1;
extern int     TSLPlus = 25;

extern string  ParamSHI_Channel= " --- SHI_Channel Parameters ---";
extern int     AllBars=240;
extern int     BarsForFract=0;

extern string  ParamMM = " --- ÌÌ Parameters ---";
extern double  ExtMaxRisk = 0.05;

//------
int MagicBuyStop = 3101;
int MagicSellStop = 3102;
int MagicBuyLimit = 3103;
int MagicSellLimit = 3104;
int glbOrderType;
int glbOrderTicket;

//------SHI_Channel variables
int CurrentBar=0;
double Step=0;
int B1=-1,B2=-1;
int UpDown=0;
double P1=0,P2=0,PP=0;
int i=0,AB=300,BFF=0;
int ishift=0;
double iprice=0;
datetime T1,T2;

int last_loss_order = 0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   Comment("TrendMeLeaveMe_Gold by Waddah Attar www.metaforex.net");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double vP, vA, vM, sl, tp;
   
   if(UseTrailingStop) TrailIt(TSLPlus);
   
   Show_SHI_Channel();
   
   if(ObjectFind(BuyStop_TrendName) == 0)
     {
       SetObject("Active" + BuyStop_TrendName,
                 ObjectGet(BuyStop_TrendName, OBJPROP_TIME1),
                 ObjectGet(BuyStop_TrendName, OBJPROP_PRICE1) + BuyStop_StepActive*Point,
                 ObjectGet(BuyStop_TrendName, OBJPROP_TIME2),
                 ObjectGet(BuyStop_TrendName, OBJPROP_PRICE2) + BuyStop_StepActive*Point,
                 ObjectGet(BuyStop_TrendName, OBJPROP_COLOR));
       SetObject("Prepare" + BuyStop_TrendName,
                 ObjectGet(BuyStop_TrendName, OBJPROP_TIME1),
                 ObjectGet(BuyStop_TrendName, OBJPROP_PRICE1) - BuyStop_StepPrepare*Point,
                 ObjectGet(BuyStop_TrendName, OBJPROP_TIME2),
                 ObjectGet(BuyStop_TrendName, OBJPROP_PRICE2) - BuyStop_StepPrepare*Point,
                 ObjectGet(BuyStop_TrendName, OBJPROP_COLOR));
       vA = NormalizeDouble(ObjectGetValueByShift("Active"+BuyStop_TrendName,0),Digits);
       vM = NormalizeDouble(ObjectGetValueByShift(BuyStop_TrendName,0),Digits);
       vP = NormalizeDouble(ObjectGetValueByShift("Prepare"+BuyStop_TrendName,0),Digits);
       sl = vA - BuyStop_StopLoss*Point;
       tp = vA + BuyStop_TakeProfit*Point;
       if(Ask <= vM && Ask >= vP && OrderFind(MagicBuyStop) == false)
           if(OrderSend(Symbol(), OP_BUYSTOP, PosSize(), vA, 3, sl, tp,
              "", MagicBuyStop, 0, Green) < 0)
               Print("Err (", GetLastError(), ") Open BuyStop Price= ", vA, " SL= ", 
                     sl," TP= ", tp);

       if(Ask <= vM && Ask >= vP && OrderFind(MagicBuyStop) == true && 
          glbOrderType == OP_BUYSTOP)
         {
           OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES);
           if(vA != OrderOpenPrice())
               if(OrderModify(glbOrderTicket, vA, sl, tp, 0, Green) == false)
                   Print("Err (", GetLastError(), ") Modify BuyStop Price= ", vA, 
                         " SL= ", sl, " TP= ", tp);
         }

       if(Ask < vP && OrderFind(MagicBuyStop) == true && 
          glbOrderType == OP_BUYSTOP && AutoClose==true)
         {
           OrderDelete(glbOrderTicket);
         }
     }

   if(ObjectFind(BuyLimit_TrendName) == 0)
     {
       SetObject("Active" + BuyLimit_TrendName,
                 ObjectGet(BuyLimit_TrendName, OBJPROP_TIME1),
                 ObjectGet(BuyLimit_TrendName, OBJPROP_PRICE1) + BuyLimit_StepActive*Point,
                 ObjectGet(BuyLimit_TrendName, OBJPROP_TIME2),
                 ObjectGet(BuyLimit_TrendName, OBJPROP_PRICE2) + BuyLimit_StepActive*Point,
                 ObjectGet(BuyLimit_TrendName, OBJPROP_COLOR));
       SetObject("Prepare" + BuyLimit_TrendName,
                 ObjectGet(BuyLimit_TrendName, OBJPROP_TIME1),
                 ObjectGet(BuyLimit_TrendName, OBJPROP_PRICE1) + BuyLimit_StepPrepare*Point,
                 ObjectGet(BuyLimit_TrendName, OBJPROP_TIME2),
                 ObjectGet(BuyLimit_TrendName, OBJPROP_PRICE2) + BuyLimit_StepPrepare*Point,
                 ObjectGet(BuyLimit_TrendName, OBJPROP_COLOR));
       vA = NormalizeDouble(ObjectGetValueByShift("Active"+BuyLimit_TrendName,0),Digits);
       vM = NormalizeDouble(ObjectGetValueByShift(BuyLimit_TrendName,0),Digits);
       vP = NormalizeDouble(ObjectGetValueByShift("Prepare"+BuyLimit_TrendName,0),Digits);
       sl = vA - BuyLimit_StopLoss*Point;
       tp = vA + BuyLimit_TakeProfit*Point;

       if(Ask >= vM && Ask <= vP && OrderFind(MagicBuyLimit) == false)
           if(OrderSend(Symbol(), OP_BUYLIMIT, PosSize(), vA, 3, sl, tp,
              "", MagicBuyLimit, 0, Green) < 0)
               Print("Err (", GetLastError(), ") Open BuyLimit Price= ", vA, " SL= ", 
                     sl," TP= ", tp);

       if(Ask >= vM && Ask <= vP && OrderFind(MagicBuyLimit) == true && 
          glbOrderType == OP_BUYLIMIT)
         {
           OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES);
           if(vA != OrderOpenPrice())
               if(OrderModify(glbOrderTicket, vA, sl, tp, 0, Green) == false)
                   Print("Err (", GetLastError(), ") Modify BuyLimit Price= ", vA, 
                         " SL= ", sl, " TP= ", tp);
         }

       if(Ask > vP && OrderFind(MagicBuyLimit) == true && 
          glbOrderType == OP_BUYLIMIT && AutoClose==true)
         {
           OrderDelete(glbOrderTicket);
         }
     }

   if(ObjectFind(SellStop_TrendName) == 0)
     {
       SetObject("Activate" + SellStop_TrendName,
                 ObjectGet(SellStop_TrendName, OBJPROP_TIME1),
                 ObjectGet(SellStop_TrendName, OBJPROP_PRICE1) - SellStop_StepActive*Point,
                 ObjectGet(SellStop_TrendName, OBJPROP_TIME2),
                 ObjectGet(SellStop_TrendName, OBJPROP_PRICE2) - SellStop_StepActive*Point,
                 ObjectGet(SellStop_TrendName, OBJPROP_COLOR));
       SetObject("Prepare" + SellStop_TrendName, ObjectGet(SellStop_TrendName, OBJPROP_TIME1),
                 ObjectGet(SellStop_TrendName, OBJPROP_PRICE1) + SellStop_StepPrepare*Point,
                 ObjectGet(SellStop_TrendName, OBJPROP_TIME2),
                 ObjectGet(SellStop_TrendName, OBJPROP_PRICE2) + SellStop_StepPrepare*Point,
                 ObjectGet(SellStop_TrendName, OBJPROP_COLOR));
       vA = NormalizeDouble(ObjectGetValueByShift("Activate" + SellStop_TrendName, 0), Digits);
       vM = NormalizeDouble(ObjectGetValueByShift(SellStop_TrendName, 0), Digits);
       vP = NormalizeDouble(ObjectGetValueByShift("Prepare" + SellStop_TrendName, 0), Digits);
       sl = vA + SellStop_StopLoss*Point;
       tp = vA - SellStop_TakeProfit*Point;

       if(Bid >= vM && Bid <= vP && OrderFind(MagicSellStop) == false)
           if(OrderSend(Symbol(), OP_SELLSTOP, PosSize(), vA, 3, sl, tp, "", 
              MagicSellStop, 0, Red) < 0)
               Print("Err (", GetLastError(), ") Open SellStop Price= ", vA, " SL= ", sl, 
                     " TP= ", tp);

       if(Bid >= vM && Bid <= vP && OrderFind(MagicSellStop) == true && 
          glbOrderType == OP_SELLSTOP)
         {
           OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES);
           if(vA != OrderOpenPrice())
               if(OrderModify(glbOrderTicket, vA, sl, tp, 0, Red) == false)
                   Print("Err (", GetLastError(), ") Modify SellStop Price= ", vA, " SL= ", sl, 
                         " TP= ", tp);
         }

       if(Bid > vP && OrderFind(MagicSellStop) == true && 
          glbOrderType == OP_SELLSTOP && AutoClose==true)
         {
           OrderDelete(glbOrderTicket);
         }
     }

   if(ObjectFind(SellLimit_TrendName) == 0)
     {
       SetObject("Activate" + SellLimit_TrendName,
                 ObjectGet(SellLimit_TrendName, OBJPROP_TIME1),
                 ObjectGet(SellLimit_TrendName, OBJPROP_PRICE1) - SellLimit_StepActive*Point,
                 ObjectGet(SellLimit_TrendName, OBJPROP_TIME2),
                 ObjectGet(SellLimit_TrendName, OBJPROP_PRICE2) - SellLimit_StepActive*Point,
                 ObjectGet(SellLimit_TrendName, OBJPROP_COLOR));
       SetObject("Prepare" + SellLimit_TrendName, ObjectGet(SellLimit_TrendName, OBJPROP_TIME1),
                 ObjectGet(SellLimit_TrendName, OBJPROP_PRICE1) - SellLimit_StepPrepare*Point,
                 ObjectGet(SellLimit_TrendName, OBJPROP_TIME2),
                 ObjectGet(SellLimit_TrendName, OBJPROP_PRICE2) - SellLimit_StepPrepare*Point,
                 ObjectGet(SellLimit_TrendName, OBJPROP_COLOR));
       vA = NormalizeDouble(ObjectGetValueByShift("Activate" + SellLimit_TrendName, 0), Digits);
       vM = NormalizeDouble(ObjectGetValueByShift(SellLimit_TrendName, 0), Digits);
       vP = NormalizeDouble(ObjectGetValueByShift("Prepare" + SellLimit_TrendName, 0), Digits);
       sl = vA + SellLimit_StopLoss*Point;
       tp = vA - SellLimit_TakeProfit*Point;

       if(Bid <= vM && Bid >= vP && OrderFind(MagicSellLimit) == false)
           if(OrderSend(Symbol(), OP_SELLLIMIT, PosSize(), vA, 3, sl, tp, "", 
              MagicSellLimit, 0, Red) < 0)
               Print("Err (", GetLastError(), ") Open SellLimit Price= ", vA, " SL= ", sl, 
                     " TP= ", tp);

       if(Bid <= vM && Bid >= vP && OrderFind(MagicSellLimit) == true && 
          glbOrderType == OP_SELLLIMIT)
         {
           OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES);
           if(vA != OrderOpenPrice())
               if(OrderModify(glbOrderTicket, vA, sl, tp, 0, Red) == false)
                   Print("Err (", GetLastError(), ") Modify SellLimit Price= ", vA, " SL= ", sl, 
                         " TP= ", tp);
         }

       if(Bid < vP && OrderFind(MagicSellLimit) == true && 
          glbOrderType == OP_SELLLIMIT && AutoClose==true)
         {
           OrderDelete(glbOrderTicket);
         }
     }

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool OrderFind(int Magic)
  {
   glbOrderType = -1;
   glbOrderTicket = -1;
   int total = OrdersTotal();
   bool res = false;
   for(int cnt = 0 ; cnt < total ; cnt++)
     {
       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       if(OrderMagicNumber() == Magic && OrderSymbol() == Symbol())
         {
           glbOrderType = OrderType();
           glbOrderTicket = OrderTicket();
           res = true;
         }
     }
   return(res);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetObject(string name,datetime T1,double P1,datetime T2,double P2,color clr)
  {
   if(ObjectFind(name) == -1)
     {
       ObjectCreate(name, OBJ_TREND, 0, T1, P1, T2, P2);
       ObjectSet(name, OBJPROP_COLOR, clr);
       ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
     }
   else
     {
       ObjectSet(name, OBJPROP_TIME1, T1);
       ObjectSet(name, OBJPROP_PRICE1, P1);
       ObjectSet(name, OBJPROP_TIME2, T2);
       ObjectSet(name, OBJPROP_PRICE2, P2);
       ObjectSet(name, OBJPROP_COLOR, clr);
       ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
     } 
  }
//+------------------------------------------------------------------+

double PosSize()
{
  double  lot_min = MarketInfo(Symbol(), MODE_MINLOT);    // 0.1;
  double  lot_max = MarketInfo(Symbol(), MODE_MAXLOT);    // 5.0;
  double  lot_step = MarketInfo(Symbol(), MODE_LOTSTEP);  // 0.1;
  double  vol;

  if(lot_min < 0 || lot_max <= 0.0 || lot_step <= 0.0)
  {
    Print("CalculateVolume: invalid MarketInfo() results [", lot_min, ",", lot_max, ",", lot_step, "]");
    return(0);
  }

  if(AccountLeverage() <= 0)
  {
    Print("CalculateVolume: invalid AccountLeverage() [", AccountLeverage(), "]");
    return(0);
  }

  /* basic formula */
  vol = NormalizeDouble(AccountFreeMargin() * ExtMaxRisk / AccountLeverage() / 10.0, 2);

  /* additional calculation */
  int orders = OrdersHistoryTotal();
  int wines = 0,losses = 0;
  if(AccountBalance() > 0)
  {
  for(int i = 0; i <= orders - 1; i++)
      {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) == false)
         {
            Print("Error in history!");
            break;
         }

         //----
         if(OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue;

         //----
         if(OrderProfit() > 0) continue;

         //----
         if(OrderProfit() < 0)
         {
            losses++;
            last_loss_order = i;
         }
      }

      //----
      if(losses > 0) // {lot = NormalizeDouble(lot/(losses+1), 1);
        vol = NormalizeDouble(vol - lot_step*losses , 1);

   for(i = last_loss_order; i <= orders - 1; i++)
      {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) == false)
         {
            Print("Error in history!");
            break;
         }

         //----
         if(OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue;

         //----
         if(OrderProfit() > 0) wines++;

         
      }

      if(wines > 0) vol = NormalizeDouble(AccountFreeMargin() * ExtMaxRisk / AccountLeverage() / 10.0, 2);
   }

  vol = NormalizeDouble(vol / lot_step, 0) * lot_step;
  if(vol < lot_min) vol = lot_min;
  if(vol > lot_max) vol = lot_max;
  return(vol);
}

void TrailIt( int byPips)
{
   if(byPips >= 5)
   {
      for(int i = 0; i < OrdersTotal(); i++)
      {
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol() == Symbol() && OrderMagicNumber() >= MagicBuyStop && OrderMagicNumber()<=MagicSellLimit)
         {
            if(OrderType() == OP_BUY)
            {
               if(
                  MarketInfo(OrderSymbol(),MODE_BID) - OrderOpenPrice() >
                     (byPips * MarketInfo(OrderSymbol(),MODE_POINT)))
               {
                  if(
                     OrderStopLoss() < MarketInfo(OrderSymbol(),MODE_BID) -
                        (byPips * MarketInfo(OrderSymbol(),MODE_POINT)))
                  {
                     OrderModify(
                        OrderTicket(),
                        OrderOpenPrice(),
                        MarketInfo(OrderSymbol(), MODE_BID) - byPips * MarketInfo(
                              OrderSymbol(),
                              MODE_POINT),
                        OrderTakeProfit(),
                        Red);
                  }
               }
            }
            else
            {
               if(OrderType() == OP_SELL)
               {
                  if(
                     OrderOpenPrice() - MarketInfo(OrderSymbol(),MODE_ASK) > byPips * MarketInfo(
                           OrderSymbol(),
                           MODE_POINT))
                  {
                     if(
                        (
                           OrderStopLoss() > MarketInfo(OrderSymbol(),MODE_ASK) +
                           byPips *
                           MarketInfo(OrderSymbol(),MODE_POINT)
                        )
                     || (OrderStopLoss() == 0))
                     {
                        OrderModify(
                           OrderTicket(),
                           OrderOpenPrice(),
                           MarketInfo(OrderSymbol(), MODE_ASK) + byPips * MarketInfo(
                                 OrderSymbol(),
                                 MODE_POINT),
                           OrderTakeProfit(),
                           Red);
                     }
                  }
               }
            }
         }
      }
   }
}  // proc TrailIt()


void DelObj()
{
	ObjectDelete("STL1");
	ObjectDelete("STL2");
	ObjectDelete("SMIDL");
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int Show_SHI_Channel()
  {
   
   AB=AllBars; //AB-êîëè÷åñòâî îáñ÷èòûâàåìûõ áàðîâ
	if (BarsForFract>0) 
		BFF=BarsForFract; 
	else
	{
		switch (Period())
		{
			case 1: BFF=12; break;
			case 5: BFF=48; break;
			case 15: BFF=24; break;
			case 30: BFF=24; break;
			case 60: BFF=12; break;
			case 240: BFF=15; break;
			case 1440: BFF=10; break;
			case 10080: BFF=6; break;
			default: DelObj(); return(-1); break;
		}
	}
	CurrentBar=2; //ñ÷èòàåì ñ òðåòüåãî áàðà, ÷òîáû ôðàêòàë "çàêðåïèëñÿ
	B1=-1; B2=-1; UpDown=0;
	while(((B1==-1) || (B2==-1)) && (CurrentBar<AB))
	{
		//UpDown=1 çíà÷èò ïåðâûé ôðàêòàë íàéäåí ñâåðõó, UpDown=-1 çíà÷èò ïåðâûé ôðàêòàë
		//íàéäåí ñíèçó, UpDown=0 çíà÷èò ôðàêòàë åù¸ íå íàéäåí.
		//Â1 è Â2 - íîìåðà áàðîâ ñ ôðàêòàëàìè, ÷åðåç íèõ ñòðîèì îïîðíóþ ëèíèþ.
		//Ð1 è Ð2 - ñîîòâåòñòâåííî öåíû ÷åðåç êîòîðûå áóäåì ëèíèþ ïðîâîäèòü

		if((UpDown<1) && (CurrentBar==Lowest(Symbol(),Period(),MODE_LOW,BFF*2+1,CurrentBar-BFF))) 
		{
			if(UpDown==0) { UpDown=-1; B1=CurrentBar; P1=Low[B1]; }
			else { B2=CurrentBar; P2=Low[B2];}
		}
		if((UpDown>-1) && (CurrentBar==Highest(Symbol(),Period(),MODE_HIGH,BFF*2+1,CurrentBar-BFF))) 
		{
			if(UpDown==0) { UpDown=1; B1=CurrentBar; P1=High[B1]; }
			else { B2=CurrentBar; P2=High[B2]; }
		}
		CurrentBar++;
	}
	if((B1==-1) || (B2==-1)) {DelObj(); return(-1);} // Çíà÷èò íå íàøëè ôðàêòàëîâ ñðåäè 300 áàðîâ 8-)
	Step=(P2-P1)/(B2-B1);//Âû÷èñëèëè øàã, åñëè îí ïîëîæèòåëüíûé, òî êàíàë íèñõîäÿùèé
	P1=P1-B1*Step; B1=0;//ïåðåñòàâëÿåì öåíó è ïåðâûé áàð ê íóëþ
	//À òåïåðü îïîðíóþ òî÷êó ïðîòèâîïîëîæíîé ëèíèè êàíàëà.
	ishift=0; iprice=0;
	if(UpDown==1)
	{ 
		PP=Low[2]-2*Step;
		for(i=3;i<=B2;i++) 
		{
			if(Low[i]<PP+Step*i) { PP=Low[i]-i*Step; }
		}
		if(Low[0]<PP) {ishift=0; iprice=PP;}
		if(Low[1]<PP+Step) {ishift=1; iprice=PP+Step;}
		if(High[0]>P1) {ishift=0; iprice=P1;}
		if(High[1]>P1+Step) {ishift=1; iprice=P1+Step;}
	} 
	else
	{ 
		PP=High[2]-2*Step;
		for(i=3;i<=B2;i++) 
		{
			if(High[i]>PP+Step*i) { PP=High[i]-i*Step;}
		}
		if(Low[0]<P1) {ishift=0; iprice=P1;}
		if(Low[1]<P1+Step) {ishift=1; iprice=P1+Step;}
		if(High[0]>PP) {ishift=0; iprice=PP;}
		if(High[1]>PP+Step) {ishift=1; iprice=PP+Step;}
	}
	//Òåïåðü ïåðåñòàâèì êîíå÷íóþ öåíó è áàð íà ÀÂ, ÷òîáû ëèíèè êàíàëà ðèñîâàëèñü ïîäëèííåå
	P2=P1+AB*Step;
	T1=Time[B1]; T2=Time[AB];

	DelObj();
	Comment (PP,P1);
	
	if (PP<P1)
	{
	ObjectCreate("STL1",OBJ_TREND,0,T2,PP+Step*AB,T1,PP); 
		ObjectSet("STL1",OBJPROP_COLOR,Lime); 
		ObjectSet("STL1",OBJPROP_WIDTH,2); 
		ObjectSet("STL1",OBJPROP_STYLE,STYLE_SOLID); 
	ObjectCreate("STL2",OBJ_TREND,0,T2,P2,T1,P1); 
		ObjectSet("STL2",OBJPROP_COLOR,Lime); 
		ObjectSet("STL2",OBJPROP_WIDTH,2); 
		ObjectSet("STL2",OBJPROP_STYLE,STYLE_SOLID); 
	ObjectCreate("SMIDL",OBJ_TREND,0,T2,(P2+PP+Step*AB)/2,T1,(P1+PP)/2);
		ObjectSet("SMIDL",OBJPROP_COLOR,Lime); 
		ObjectSet("SMIDL",OBJPROP_WIDTH,1); 
		ObjectSet("SMIDL",OBJPROP_STYLE,STYLE_DOT);
		}
		if (PP>P1)
	{
	ObjectCreate("STL2",OBJ_TREND,0,T2,PP+Step*AB,T1,PP); 
		ObjectSet("STL2",OBJPROP_COLOR,Lime); 
		ObjectSet("STL2",OBJPROP_WIDTH,2); 
		ObjectSet("STL2",OBJPROP_STYLE,STYLE_SOLID); 
	ObjectCreate("STL1",OBJ_TREND,0,T2,P2,T1,P1); 
		ObjectSet("STL1",OBJPROP_COLOR,Lime); 
		ObjectSet("STL1",OBJPROP_WIDTH,2); 
		ObjectSet("STL1",OBJPROP_STYLE,STYLE_SOLID); 
	ObjectCreate("SMIDL",OBJ_TREND,0,T2,(P2+PP+Step*AB)/2,T1,(P1+PP)/2);
		ObjectSet("SMIDL",OBJPROP_COLOR,Lime); 
		ObjectSet("SMIDL",OBJPROP_WIDTH,1); 
		ObjectSet("SMIDL",OBJPROP_STYLE,STYLE_DOT);
		}
		
//----

//----
   return(0);
  }

Comments