[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 256

 
Ivan1:

Hi all. Please help: I need to assign to a variable the value of the current "MACD bar" and to a second variable the value of the previous...

Ivan, have a look at the basic MACD Sample EA.
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);// последняя цифра задает показатель
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
 
Ivan1:
I don't need a signal line.... it's just the MACD histogram correlation - the current MACD value with the previous one, that's what I need to assign them to the variables

did you look at the link?

I will duplicate with selections:

double iMACD( string symbol, int timeframe, int fast_ema_period, int slow_ema_period, int signal_period, int applied_price, int mode, int shift)

symbol - Symbol name of the symbol, on whose data the indicator will be calculated. NULL means current symbol.
timeframe - Period. Can be one of the periods of the chart. 0 means period of current chart.
fast_ema_period - Averaging period for calculating the fast moving average.
slow_ema_period - Averaging period for calculating a slow moving average.
signal_period - Averaging period for signal line calculation.
applied_price - Price used. Can be any of the price constants.
mode - Indicator line index. Can be any of the indicator line identifiers.
shift - Shift - index of the value, obtained from the indicator buffer (shift relative to the current bar for a specified number of periods back).

mode - index of the indicator line - here you need to specify which of the lines you need - line or histogram

shift - index of the received value. you need two values:

shift = 1 - previous value

shift = 0 - current value

 
Hello all. I'm confused. How do I know the slate of a vertical line in a subwindow?
 

I noticed for a long time that in the "account history" the orders closed at TakeProfit have [tp] in the comments, and some have tp/a...

What is the difference ?

Regards Bradman

 
143alex:
Hello, everyone. I'm confused. How do I find out the slate of a vertical line in a subwindow?

Tried this.

 double prise=ObjectGet( "L", OBJPROP_PRICE1) ;
   int    shift=ObjectGetShiftByValue( "L", prise); 
   Comment("1",shift);
 
143alex:

Tried this


ObjectGetShiftByValue "Applies to trend lines and similar objects"

Use the iBarShift function

 
yosuf:
On this forum I recently read an idea that if you open 2 differently directed orders with the same SL at the same time, then after one of them closes you can try to make a profit. Has anybody checked this idea or not? Maybe there is a similar EA?

Expert Grid v.2.

"Copyright©2008 EAfactory.com and Expert-4x.com - "Revision: 264".

Opens positions in both directions and closes both if the difference is positive.

 

Tell me where i went wrong plz... or if it's MT4 itself, but my Buy orders open only on High bar, and Sell orders only on Close bar =) Although I haven't even stipulated these conditions in the Expert Advisor's code =)

 extern int TP = 200; 
     extern int TS = 50; 
     extern int TF = 1; 
     extern double lots = 0.1; 
     extern int Pips = 15; 
     extern int MaxPips = 100; 


     int slip = 3; 
     int Magic = 2; 
     int cnt,ticket,total; 

 //+------------------------------------------------------------------+ 
  //| expert initialization function | 
  //+------------------------------------------------------------------+ 
  int init() 
    { 
  //---- 

 //---- 
     return(0); 
    } 
  //+------------------------------------------------------------------+ 
  //| expert deinitialization function | 
  //+------------------------------------------------------------------+ 
  int deinit() 
    { 
  //---- 

 //---- 
     return(0); 
    } 
  //+------------------------------------------------------------------+ 
  //| expert start function | 
  //+------------------------------------------------------------------+ 

 int start() 
    { 
  //---- 

 static double PriceOld = 0.0; 
 double PriceNow; 
 PriceNow = NormalizeDouble(Bid,6); 

 total = OrdersTotal(); 
 if(total < 1) 
 { 
    if((PriceNow-PriceOld)>=Pips*Point && (PriceNow-PriceOld)<MaxPips*Point) 
    { 
           ticket = OrderSend(Symbol(),OP_BUY,lots,Ask,slip,Bid-TS*Point,0,0,Magic,0,Green); 
    } 

 if((PriceNow-PriceOld)<=(-Pips)*Point && (PriceNow-PriceOld)>(-MaxPips)*Point) 
     { 
           ticket = OrderSend(Symbol(),OP_SELL,lots,Bid,slip,Ask+TS*Point,0,0,Magic,0,Red); 
     } 
 } 


PriceOld = PriceNow;

//---- 


return(0);
}


 
CLAIN:

Tell me where i went wrong plz... or if it's MT4 itself, but my Buy orders open only on High bar, and Sell orders only on Close bar =) Although I haven't even stipulated these conditions in the Expert Advisor's code =)


Let me guess, perhaps you are using this EA in the tester in the " open price" mode, because it shouldn't work in normal mode.
 
mmm.... no way.... using "all ticks"... so the interesting thing is, buy opens on HIGH and sell on CLOSE... i don't understand what this is about?
Reason: