MQL4 Learning - page 17

 
MQL4:
Can someone code this?

On MT4, the default color of the bars are green, right?

Well, can someone make all of the bars green, and make the bars :

22:55 and 16:30 red?

Challenging, huh? Or maybe easy for You.

God Bless You all!!!

I love You!!! Thank You, I am so happy right now!!!

Thank You!!!

Please, read this: Coloring newly forming bar - Forex Trading Software Forum and this:Change Bar Color - Forex Trading Software Forum

 

Perhaps someone can modify this, It currently paints the bars red, at 22:50 and 16:30, but the other bars are still normal colors.

If I get chance I'll see if I can improve this for you.

regards

zu

Files:
timebar.mq4  4 kb
 
 

Thank You Mladen!!!!!!!!!!!!!!

 

I have some questions, if You don't mind coders....

int start()

{

double haHigh, haLow;

string date;

ExtCountedBars=IndicatorCounted();

if (ExtCountedBars<0) return(-1);

if (ExtCountedBars>0) ExtCountedBars--;

int i=Bars-ExtCountedBars-1;

while(i>=0)

{

haHigh=High;

haLow=Low;

if ((TimeHour(iTime(NULL,0,i))==22 && TimeMinute(iTime(NULL,0,i))==55) ||

(TimeHour(iTime(NULL,0,i))==16 && TimeMinute(iTime(NULL,0,i))==30))

{

ExtMapBuffer1=haHigh;

ExtMapBuffer2=haLow;

}

else

{

ExtMapBuffer1=haLow;

ExtMapBuffer2=haHigh;

}

i--;

}

//----

return(0);

}

//+------------------------------------------------------------------+

Can You please just do the //comments, and PLEASE explain each line for me please, I want to be able to understand each line

 
 

Thank You Michel,

I agree with You. Also,

I modified everything, can You please check it, and change mistakes???

At 12:30 it is to set a buystop 10 pips above the current price, and set a sellstop 10 pips below the current pirce.

//+------------------------------------------------------------------+

//| Eagle.mq4 |

//| |

//| |

//+------------------------------------------------------------------+

#property copyright ""

#property link ""

//Input Parameters----------------------------------------------------

extern double StopLoss = 10;

extern double TakeProfit = 20;

extern double TrailingStop = 10;

extern double Lots = 1.0;

extern int ShiftUP = 10; //How much pips to buy above price

extern int ShiftDOWN = 10; //How much pips to sell below price

extern int StartHour = 12;

extern int StartMinute = 30;

extern int StartSecond = 00;

int Magic=10000000000000;

//Start Coding---------------------------------------------------------

int start()

{

if (OrdersTotal()==0)

{

if (Hour()==StartHour)

{

if (Minute()>=StartMinute)

{

if (Seconds()>=StartSecond)

{

OrderSend(Symbol(),OP_BUYSTOP,Lots,Ask+ShiftUP*Point,3,Ask-StopLoss*Point+ShiftUP*Point,Ask+TakeProfit*Point+ShiftUP*Point,"learn the syntax",Magic,0,Green);

OrderSend(Symbol(),OP_SELLSTOP,Lots,Bid-ShiftDOWN*Point,3,Bid+StopLoss*Point-ShiftDOWN*Point,Bid-TakeProfit*Point-ShiftDOWN*Point,"learn the syntax",Magic,0,Green);

}

}

}

}

Return(0);

}

I woke up today, and I ran the Eagle in real-time, and it only set a buystop. Then, I did it a second time, and it did everything right. Then, I did it the third time, and it only made a sellstop. I think something is wrong with my code, can You please check it Michel, or anyone.

 

New, Fresh Questios

1)What is the code to have a comment at the bottom left corner a certain color, and font, and font size? For example, I want the comment to say: Good Day being blue colored, Papyrus font, 10 size font.

2)If I have, for example 5 orders open, I what is the code to close, for example, the 1st order, not all of them?

3)Are there codes for milliseconds, or even smaller?

4)If I bought, for example, I want a trailingstop 2 pips under each low of a new bar.

Thank You,

MQL4.

 

Make sure you use prefix such as "pbstat", so you can use another function to delete them in deinit()

void objectCreate(string name,int x,int y,string text="-",int size=42,

string font="Arial",color colour=CLR_NONE)

{

ObjectCreate(name,OBJ_LABEL,0,0,0);

ObjectSet(name,OBJPROP_CORNER,PBCorner);

ObjectSet(name,OBJPROP_COLOR,colour);

ObjectSet(name,OBJPROP_XDISTANCE,x);

ObjectSet(name,OBJPROP_YDISTANCE,y);

ObjectSetText(name,text,size,font,colour);

}

void DeleteAllObjects()

{

int objs = ObjectsTotal();

string name;

for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)

{

name=ObjectName(cnt);

if (StringFind(name,"pbstat",0)>-1) ObjectDelete(name);

ObjectsRedraw();

}

}

 

Code Confusion!

envtop_cur0=iEnvelopes(NULL,0,30,0,5,0,-0.04,2,0);//TopBand

envbottom_cur0=iEnvelopes(NULL,0,30,0,5,0,0.04,1,0);//BottomBand

Something is not right with above - Can someone spot and fix this code??

Dave

<<<

Much thanks in advance!!
Reason: