[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 185

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
If you could do it in code, I've been racking my brains :)
What could be the problem? The indicator showed several pieces during the test and the EA looped in what could be the problem with the indicator?
In which variable is the value of OsMA stored?
//+------------------------------------------------------------------+
//| OsMA.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp.
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
#property indicator_width1 2
//---- indicator parameters
extern int FastEMA=12;
extern inttern SlowEMA=26;
extern inttern SignalSMA=9;
//---- indicator buffers
double OsmaBuffer[];
double MacdBuffer[];;
double SignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialisation function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexDrawBegin(0,SignalSMA);
IndicatorDigits(Digits+2);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,OsmaBuffer);
SetIndexBuffer(1,MacdBuffer);
SetIndexBuffer(2,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("OsMA("+FastEMA+", "+SlowEMA+", "+SignalSMA+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Average of Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1st additional buffer
for(int i=0; i<limit; i++)
MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2nd additional buffer
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
//---- main loop
for(i=0; i<limit; i++)
OsmaBuffer[i]=MacdBuffer[i]-SignalBuffer[i];
//---- done
return(0);
}
//+------------------------------------------------------------------+
This variant will do
Thank you very much! Although I haven't dealt with functions, now I need to figure out how to call it, pass the variable values to it, and get the values back. If I understand the mechanism correctly.
In which variable is the value of OsMA stored?
isn't it in the buffer ?
>> but isn't it in the buffer?
>> What buffer?
Which one?
OsmaBuffer[]
>> which one?
дабавте перед
Alert("Значения MacdBuffer[i]="MacdBuffer[i]);
Alert("Значения SignalBuffer[i]="SignalBuffer[i]);
Alert("Значения OSMA ="OsmaBuffer[i]);
return(0);
}
just have to normalise the values
Hello.
Why isn't the stop transferring for buy positions? for sell positions everything works.
if(OrdersTotal()>0)
{
if(Bid==buy||Bid==busell)
{
OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES);
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(), 0, Blue);
}
return(0);
}
What could be the problem? The indicator showed several pieces during the test, and the EA looped in what could be the problem of the indicator?
Incorrectly set parameters (by number or type) in the EA.
Alternatively, remove all string parameters from the indicator.