Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 236
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
... all currency pairs where USD is present ...
There is no calculation of "margin used from trading funds" in the code ... and at the end of my first post I noted"switching the deposit currency view in the tester does not fix the problem."
There is no calculation of "margin used from trading funds" in the code ... and at the end of my first post I noted"switching the deposit currency type in the tester does not fix the problem".
Then my telepathic powers are over - lay out the code.
Sorry for the question, I know how to insert an external indicator into an EA using a buffer... But there is no buffer in this indicator, how do I get the upper and lower price.
//+------------------------------------------------------------------+
//| trendlinesDay.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| https://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "nsi2000"
#property link "http://www.expert-mt4.nm.ru"
//----
#property indicator_chart_window
//---- input parameters
extern int nPeriod=10;
extern int Limit=350;
double Up[];
double Dn[];
///---- int Widners Oscilator
int cnt,nCurBar=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- Output in Char
for(cnt=0; cnt<=5; cnt++)
{
ObjectCreate("WSO-"+cnt,OBJ_HLINE,0,0,0);
ObjectSet("WSO-"+cnt,OBJPROP_COLOR,Red);
if(cnt<5)
{
ObjectCreate("Trend DN-"+cnt,OBJ_TREND,0,0,0,0,0);
ObjectSet("Trend DN-"+cnt,OBJPROP_COLOR,Magenta);
}
//----
ObjectCreate("WRO-"+cnt,OBJ_HLINE,0,0,0);
ObjectSet("WRO-"+cnt,OBJPROP_COLOR,Blue);
if(cnt<5)
{
ObjectCreate("Trend UP-"+cnt,OBJ_TREND,0,0,0,0,0);
ObjectSet("Trend Up-"+cnt,OBJPROP_COLOR,Aqua);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
for(cnt=0; cnt<=5; cnt++)
{
ObjectDelete("Trend UP-"+cnt);
ObjectDelete("Trend DN-"+cnt);
ObjectDelete("WSO-"+cnt);
ObjectDelete("WRO-"+cnt);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//---- TODO: add your code here
double r1,r2,r3,r4,r5,r6;
int rt1,rt2,rt3,rt4,rt5,rt6;
double s1,s2,s3,s4,s5,s6;
int st1,st2,st3,st4,st5,st6;
//---- Линии сопротивления и поддержки
if(Bars<Limit) Limit=Bars-nPeriod;
for(nCurBar=Limit; nCurBar>0; nCurBar--)
{
if(Low[nCurBar+(nPeriod-1)/2]==Low[Lowest(NULL,0,MODE_LOW,nPeriod,nCurBar)])
{
s6=s5; s5=s4; s4=s3; s3=s2; s2=s1; s1=Low[nCurBar+(nPeriod-1)/2];
st6=st5; st5=st4; st4=st3; st3=st2; st2=st1; st1=nCurBar+(nPeriod-1)/2;
}
if(High[nCurBar+(nPeriod-1)/2]==High[Highest(NULL,0,MODE_HIGH,nPeriod,nCurBar)])
{
r6=r5; r5=r4; r4=r3; r3=r2; r2=r1; r1=High[nCurBar+(nPeriod-1)/2];
rt6=rt5; rt5=rt4; rt4=rt3; rt3=rt2; rt2=rt1; rt1=nCurBar+(nPeriod-1)/2;
}
}
//---- Move Object in Chart
ObjectMove("Trend DN-0",1,Time[st1],s1);
ObjectMove("Trend DN-0",0,Time[st2],s2);
//----
ObjectMove("Trend UP-0",1,Time[rt1],r1);
ObjectMove("Trend UP-0",0,Time[rt2],r2);
//----
return(0);
}
//+------------------------------------------------------------------+
Sorry for the question, I know how to insert an external indicator into an EA using a buffer... In this indicator there is no buffer, how do I get the upper and lower price
Take graphical objects on the chart with names "Trend DN-0", "Trend UP-0" (those lines that indicate some levels of the indicator) and read the desired data from them
on the chart take graphical objects with the names "Trend DN-0", "Trend UP-0" (those lines with which the indicator marks some levels) and read the necessary data from them
please write how to do this in the indicator itself? and then make 2 buffers from these values to use them in the EA?
Write in which place to take the price?
please write how to do this in the indicator itself? and then make 2 buffers from these values to use them in the EA?
write in which place to take the price?
The indicator already has all the data to calculate two buffers and draw them.
And you have not offered to change the indicator, but to read the data of lines drawn by the indicator from the Expert Advisor.
However, this imposes restrictions on the use of the tester - only in visual mode you will be able to test the Expert Advisor.
The indicator already has all the data to calculate the two buffers and draw them.
And you have not been suggested to change the indicator, but to read the data of lines drawn by the indicator from the Expert Advisor.
However, this imposes limitations on the use of the tester - you will only be able to test the Expert Advisor in visual mode.
It means I should write in the indicator
#property indicator_buffers 2
double BufferUp[], BufferDn[];
int OnInit()
{
SetIndexBuffer(0, BufferUp)
SetIndexBuffer(1, BufferDn)
}
And then exactly with what? I have to link these 2 buffers?
So I have to write in the indicator
#property indicator_buffers 2
double BufferUp[], BufferDn[];
int OnInit()
{
SetIndexBuffer(0, BufferUp)
SetIndexBuffer(1, BufferDn)
}
And then exactly with what? I have to link these 2 buffers?
Look: you have lines moving in your code:
Time[st1], Time[st2] and the price of these reference points s1, s2 are for one line,
Time[rt1], Time[rt2], r1, r2 - for another line.
Using the line equation you can calculate the buffer value for each bar between these points and write this value into the buffer.
See: you have lines moving in your code:
We have Time[st1], Time[st2] and the price of these points s1, s2 - for one line,
Time[rt1], Time[rt2], r1, r2 - for another line.
Using the straight line equation you can calculate the buffer value for each bar between these points and write this value into the buffer.
so you can't just take the price of the line over the bar... I don't know how to calculate the straight line equation, if possible, write how it all should look like.
And, in general, the value should not be taken between points, but over 0 or 1 bar