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

 
Tema97:

what do i do now ??? i have a channel-based strategy - is there an alternative replacement ?

What is there to build in for ? Query the indicator via iCustom.
For selling, you can embed with#resource
 
I want to implement the following
the ability to add different timeframes to ONE sheet (in different windows but on one sheet)
Please advise where to go and where to dig?) is it possible through mql or WInApi?
maybe there are examples of the article i could not find(
 
kocunyc89:

please help me to fix this! it gives error 'Void' - declaration without type 36 4 and where to rearrange or write return?
//--------------------------------------------------------------------
Void OnTick()
{

void is written with a small lowercase instead of uppercase. Look, it's a different colour. Put cursor on this word and press F1 - it often helps.

So many error messages appear after fixing it... I fixed the error messages, but check the logic yourself

#property strict

bool Результат;

extern int   SL             = 200,      //Стоплосс в пунктах
             TStop          = 20,       //
             TStep          = 10,       //
             TP             = 85;       //Тейкпрофит в пунктах
//extern double Lot          = 0.10;     //используется только при risk = 0
extern double Lots           =  0;       // лот, если 0, то динамический
extern double RiskPercentage =  50;      // % от депо на лот, если динамический
extern int    MaxOrders      = 6;        //Максимальное кол-во ордеров одного направления

//--------------------------------------------------------------------
int STOPLEVEL,Magic=123321,tip;
datetime TimeBar;

string txt;
//--------------------------------------------------------------------
int init()
{
   if(Digits==3||Digits==5)
   {
      TStop *=10;
      TStep *=10;
      SL    *=10;
   }
   return(INIT_SUCCEEDED);
}


//--------------------------------------------------------------------
void OnTick()
{
  double Lot = Lots;
  int Ticket = 0;
  if (Lots==0)
  {
    double margin = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
    double minLot = MarketInfo(Symbol(), MODE_MINLOT);
    double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);
    double step   = MarketInfo(Symbol(), MODE_LOTSTEP);
    double account = AccountFreeMargin();
    double percentage = account*RiskPercentage/100;
  
    Lot = MathRound(percentage/margin/step)*step;
  
    if(Lot < minLot) Lot = minLot;

    if(Lot > maxLot)Lot = maxLot;
  }

  int buy=0,sell=0;
  for (int i=0; i<OrdersTotal(); i++)
  {
    if (OrderSelect(i, SELECT_BY_POS))
    {
         if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
         tip=OrderType();
         if (tip==0) buy++;
         if (tip==1) sell++;
    }  
  }

  Comment(txt,"\nБаланс ",DoubleToStr(AccountBalance(),2),"\nЭквити ",DoubleToStr(AccountEquity(),2),"\nBuy ",buy,"\nSel ",sell);
  double TrPr=0,StLo=0;
  double L    = NormalizeDouble(Low[0], Digits);
  double L1   = NormalizeDouble(Low[1], Digits);
  double L2   = NormalizeDouble(Low[2], Digits);
  double L3   = NormalizeDouble(Low[3], Digits);

  double H   = NormalizeDouble(High[0],Digits);
  double H1  = NormalizeDouble(High[1],Digits);
  double H2  = NormalizeDouble(High[2],Digits);
  double H3  = NormalizeDouble(High[3],Digits);

  double O   = NormalizeDouble(Open[0], Digits);
  double O1  = NormalizeDouble(Open[1], Digits);
  double O2  = NormalizeDouble(Open[2], Digits);
  double O3  = NormalizeDouble(Open[3], Digits);

  double C   = NormalizeDouble(Close[0],Digits);
  double C1  = NormalizeDouble(Close[1],Digits);
  double C2  = NormalizeDouble(Close[2],Digits);
  double C3  = NormalizeDouble(Close[3],Digits);

                         //LONG
  if (buy<MaxOrders  && TimeBar!=Time[0]&& H>H1&&H1>H2&&H2>H3)
  {
    if (TP!=0) TrPr = NormalizeDouble(Ask + TP * Point,Digits);
    if (SL!=0) StLo = NormalizeDouble(Bid - SL * Point,Digits);
    Ticket=OrderSend(Symbol(),OP_BUY, Lots,NormalizeDouble(Ask,Digits),3,0,0,"BreakdownLevelCandleMA",Magic,0,Blue);
    if (Ticket==0)
    Print("Error BUY",GetLastError(),"",Symbol(),"   Lot ",Lot,"   SL ",StLo,"   TP ",TrPr);
    else
    {
      Результат=OrderModify(Ticket,OrderOpenPrice(),StLo,TrPr,0,Blue);
      TimeBar=Time[0];
    }
  }

                                  //SHORT
  if (sell<MaxOrders && TimeBar!=Time[0]&& L>L1&&L1>L2&&L2>L3)
  {
    if (TP!=0) TrPr = NormalizeDouble(Bid - TP * Point,Digits);
    if (SL!=0) StLo = NormalizeDouble(Ask + SL * Point,Digits);
    Ticket=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),3,0,0,"BreakdownLevelCandleMA",Magic,0,Red);
    if (Ticket==0)
    Print("Error SELL",GetLastError(),"",Symbol(),"   Lot ",Lot,"   SL ",StLo,"   TP ",TrPr);
    else
    {
      Результат=OrderModify(Ticket,OrderOpenPrice(),StLo,TrPr,0,Red);
      TimeBar=Time[0];
    }
  }

  Trailing();
}
//!!! куда передвинуть?   return(0);


void Trailing()
{
  for(int i=OrdersTotal() -1; i>=0; i--)
  {
    if (OrderSelect(i, SELECT_BY_POS,MODE_TRADES))
    {
      if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
      {
        if(OrderType()==OP_BUY)
        {
          if (Bid-OrderOpenPrice()> TStop*Point || OrderStopLoss() ==0)
          {
            if(OrderStopLoss()<Bid-(TStep+TStop)*Point || OrderStopLoss() ==0)
            {
              if(!OrderModify(OrderTicket(), OrderOpenPrice(),NormalizeDouble(Bid-TStop*Point, Digits),0,0))
              Print("Ошибка модификации ордера на покупку");
            }
          }
        }

        if(OrderType()==OP_SELL)
        {
          if (OrderOpenPrice()-Ask>TStop*Point || OrderStopLoss() ==0)
          {
            if((OrderStopLoss()> (Ask+(TStep+TStop)*Point))  || (OrderStopLoss()==0)  )
            {
              if(!OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+TStop*Point,Digits),0,0))
                {
                        Print("Ошибка модификации ордера на продажу");
                }
            }
          }
        }
      }
    }
  }
}

 
LRA:

void is written with a small lower case, not a large uppercase. See if it's a different colour. Put cursor on this word and press F1 - it often helps.

After fixing it so many error messages appear... Fixed the error messages, but check the logic yourself


Thank you very much kind man!

 
Hello, gentlemen traders! I wrote a signal robot based on the code I posted above. The robot generates signals for options almost accurately, but with a lag of two bars. What should I change in the code to produce the same results but two bars earlier? Or is it impossible? Thank you.
 
Can you please advise me - I have a custom indicator - Channel - I need to return the value of the upper limit of the channel - how can I do this ?
 
artmedia70:

The int variable contains exactly the number of seconds since 1970, while the datetime variable contains the date.

If you need a certain bar in the history, then it does not matter how you specify it - by date or by number of seconds, in any case, the variable will indicate the time of opening this particular bar, regardless of the arrival of new ticks and opening of new bars.

Thanks a lot, but there is one more problem. I have indicator that has stat function, this function should be used ONLY when I get new signal, but this problem is on every bar, I've done everything and I've normalized it, I comparing it. Killed the whole evening, can someone explain what is wrong ???? Indicator in the atache in the 193 line is a function call with a condition, but the condition is not met and Furction stat is counted at the arrival of each bar, I'm already sick and tired to find the error, guys help please!!!!! Thanks in advance....
Files:
 

I found out only now that the stat function is recalculated if the indicator is called from another indicator, when both of them are on the chart. That is, once it is calculated for itself and the second time for the indicator that calls it. What is it?

 

The following is shown in the picture. The comment at the top is the buffer value in the main indicator in which the calculation takes place, and the print (below) is the same buffer, but only called in another indicator and outputted in the print. The difference is significant, BUT WHY!!!!!

the first file is the main one, the second one calls the buffer from the first one....

Files:
 
nikelodeon:

The difference is significant, but WHY!!!!!

The difference could be from calling at different times or a difference in calling parameters. And the extra call... We had a similar case recently. We have a T that is supposed to be triggered by a call. But the bell had two buttons: the right one for our boss and an extra one for Skunk from the neighbouring department. The boss found the wire and cut it off and told Scoon, "Either start your own N, or trigger it yourself. How copy? Over!!!
Reason: