[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 270

 

Hi all.

Need help - tell me how to do this in EA:

Overlay one indicator on another?

I call the first indicator, it takes values from the chart.

How to call the second one, so that it takes values from the first one?

If possible, with an example (let's apply the muwings to atp).

Thank you in advance.

 

Can you guys please tell me where in the code there is an error? The Expert Advisor only buys... After a stop or a take, it waits until the bar closes and buys again... If I swap buy and sell on the first few lines, it just sells... Please tell me what it may be...

if (PerkyBuf1!=0 && OrdCon(MG)==0) {OrderOp(OP_SELL,Lots);  
    }  
    if (PerkyBuf2!=0 && OrdCon(MG)==0) {OrderOp(OP_BUY,Lots);  
    }
 }

return(0);
}


int OrderOp(int ord,double lot)  
{
   int ticket1;
   string ccm="";
   double l;
   bool SLTP;
   
   
   if (ord==OP_BUY) {
      l=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK), MarketInfo(Symbol(), MODE_DIGITS));
      ccm="pivot: BUY";
      ticket1=OrderSend(Symbol(),ord,lot,l,3,0,0,ccm,MG,0,White);
      if (ticket1!=0) {
            if (StopLoss!=0) {SL=NormalizeDouble(l-StopLoss*Point,Digits);}
            if (TakeProfit!=0) {TP=NormalizeDouble(l+TakeProfit*Point,Digits);}
            SLTP=OrderModify(ticket1,OrderOpenPrice(),SL,TP,0,Red);
            if (SLTP) {return(0);}
      } 
   }           
   
   if (ord==OP_SELL) {
      l=NormalizeDouble(MarketInfo(Symbol(), MODE_BID), MarketInfo(Symbol(), MODE_DIGITS));
      ccm="pivot: SELL";
      ticket1=OrderSend(Symbol(),ord,lot,l,3,0,0,ccm,MG,0,White);
      if (ticket1!=0) {
            if (StopLoss!=0) {SL=NormalizeDouble(l+StopLoss*Point,Digits);}
            if (TakeProfit!=0) {TP=NormalizeDouble(l-TakeProfit*Point,Digits);}
            SLTP=OrderModify(ticket1,OrderOpenPrice(),SL,TP,0,Red);
            if (SLTP) {return(0);}
 
Mihoi:

Hi all.

Need help - tell me how to do this in EA:

Overlay one indicator on another?

I call the first indicator, it takes values from the chart.

How to call the second one, so that it takes values from the first one?

If possible, with an example (let's apply the muwings to atp).

Thank you in advance.

In the ATR indicator itself enter a few extra lines.

A good example to solve the problem would be MACD indicator from the group of custom indicators.

Open the MACD indicator code and see how it is done.

It is very simple. iMAOnArray().

 
ostrik:

Can you guys please tell me where in the code there is an error? The Expert Advisor only buys... After a stop or a take, it waits until the bar closes and then buys again... If I swap buy and sell on the first few lines, it just sells... Please tell me what it may be...


if (PerkyBuf1!=0 && OrdCon(MG)==0) {OrderOp(OP_SELL,Lots);  
    }  
    if (PerkyBuf2!=0 && OrdCon(MG)==0) {OrderOp(OP_BUY,Lots);  
    }
 } --- может, эта скобка лишняя???
 
Thanks, I'll give it a try!
 
DhP:



No, the bracket seems fine...
 
ostrik:

No, brackets are fine...

You guys are kind of hinting that you've provided incomplete code with an incomplete function.

In fact, Print or Comment rules.

 
sergeev:

You guys are kind of hinting that you've provided incomplete code with an incomplete function.

In general, Print or Comment rules.


The thing is, I'm just learning this hard stuff and I can't do anything at all... I have the feeling that my hands aren't growing in the right place ))

 

Hi, how to move the indicator line forward by a bar?

#property copyright "autoforex"
#property link "http://www.autoforex.ru"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 2
#property indicator_style1 0

double Buffer1[];

int init()
{
SetIndexBuffer(0,Buffer1);
SetIndexStyle(0,DRAW_LINE);
return(0);
}
int start()
{
for(int i=0;i<Bars;i++)
{
Buffer1[i]=High[i];
}
return(0);
}

I have an idea instead of Buffer1[i]=High[i]; put Buffer1[i-1]=High[i]; but alas it does not draw forward(

 
tmt0086:

Hi, how to move the indicator line forward by a bar?

#property copyright "autoforex"
#property link "http://www.autoforex.ru"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 2
#property indicator_style1 0

double Buffer1[];

int init()
{
SetIndexBuffer(0,Buffer1);
SetIndexStyle(0,DRAW_LINE);
return(0);
}
int start()
{
for(int i=0;i<Bars;i++)
{
Buffer1[i]=High[i];
}
return(0);
}

I have an idea instead of Buffer1[i]=High[i]; put Buffer1[i-1]=High[i]; but alas it does not draw forward(


figured it out
Reason: