Ask! - page 86

 
int start()

{

int limit;

int counted_bars=IndicatorCounted();

//---- check for possible errors

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

//---- the last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---- main loop

for(int i=0; i<limit; i++)

{

//---- ma_shift set to 0 because SetIndexShift called abowe

ExtBlueBuffer=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);

ExtRedBuffer=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);

ExtLimeBuffer=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);

}

//---- done

return(0);

}

Hi coders,

I try to go thorugh some MQL4 functions and bumped into this sample code as above. Could someone kindly explain:

1.)what's the reason of using "limit" variable there?

2.)I tried to run the sample code, which always returns value 2, what's the purpose of the "limit" value 2 in the for loop,

3.)which position bars does this for loop working on?

Thank you.

 

search a simple ea

hi ... i search this simple ea

daily breakout EA with trailing stop and profit lock function.

Exist?

 

#property indicator question

What is the statement to code #property indicator as a line versus a dash (default)??

Simple question, but unknown answer at present!

Dave

Appreciate you answering this for me!

 

icustom ! indicator -> ea

good morning, is a beginner of the language mq4, I would appreciate a help, I in advance thank!

the indicator has two variables:

bool TurnedUp = false

bool TurnedDown = false

how to use the function icustom in the EA, to read the values of TurnedUp and TurnedDown?

iCustom(Symbol(),"postfin",0,TurnedUp,0,0,0); ....

iCustom(Symbol(),"postfin",0,TurnedDown,0,0,0);

.....my probations, not working, possible because it deals with "bool" ??

part EA and error ..

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

//| EXPERT BASIC CALCULATION |

//| START HERE |

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

iCustom(Symbol(),"postfin",0,TurnedUp,0,0,0);

iCustom(Symbol(),"postfin",0,TurnedDown,0,0,0);

//EnterLong = TurnedUp;

// EnterShort = TurnedDown;

// EnterLong = true;

// if( TurnedUp == true ) EnterLong== true;

// EnterShort = TurnedDown;

//}

//if(icustom(Symbol(), "postfin","TurnedUp",0,0) == True && EnterLong== 1 )

//{

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

//| EXPERT BASIC CALCULATION |

//| END HERE |

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

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

//| YOU SHOULD NOT HAVE TO MODIFY ANYTHING BELOW THIS BOX |

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

// ENTER LONG CONDITION

if(EnterLong == true && CountLongs(MagicNumber)== 0)

{

 

Anybody know how to do this?

Here is what I'm trying to code:

I have a chart with an RSI attached to it. Then I drag and drop a MA into the RSI window and choose apply to "previous indicator's data". Now my moving average is using the RSI values for it's calculations.

I can't figure out how to code this into an EA. The Applied_Price values in mq4 don't have the option to choose "previous indicator's data" for the moving average.

Basically trying to get the current moving average of the current RSI.

If you know what I'm trying to do and may have a solution I would greatly appreciate any help.

Thanks,

Wolfe

 

need help for simple code

Dear colleagues!

I have a piece of code for time filter which disable EA on particular hours:

extern bool UseHourTrade = True;

extern int FromHourTrade = 8;

extern int ToHourTrade = 18;

-------------------------------------------------//

if (UseHourTrade){

if ((Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {

Comment("Non-Trading Hours!");

return(0);

____________________________________________

BUT I want to disable EA exactly on Friday before weekend. I don't need any open position after 8.00 CET on Friday. Could You do me a favour to post such kind of code or correct above mentioned code?

I ask for Your advice because I'm not a programmer

Best regards,

Warren

 

To reduce PC's resource

I saw sample code, usually each code calculate itself every ticks,

mean every single feed price from server, the group of code calculate by itself.

Then PC's at client terminal will process or calculate every ticks, this make client PC's need more resource, like RAM & CPU

Idea to reduce PC's resource & iteration at client terminal, If we can control that group of code to calculate at :

1. Every complete minutes and don't calculate at every ticks. 2. Every complete M1 bar and don't calculate at every ticks

Anyone can give sample code to do that ?

best regards,

BornToWin

 

Alert on any MTF indicator...

Codersguru,

Is it possible to add an Alert (preferably a voice) to a MTF indicator? I want to have the Alert sound when all 3 criteria are met in my RSI-3TF if possible.

Thank you for replying.

Sincerely.

 
BornToWin:
I saw sample code, usually each code calculate itself every ticks,

mean every single feed price from server, the group of code calculate by itself.

Then PC's at client terminal will process or calculate every ticks, this make client PC's need more resource, like RAM & CPU

Idea to reduce PC's resource & iteration at client terminal, If we can control that group of code to calculate at :

1. Every complete minutes and don't calculate at every ticks. 2. Every complete M1 bar and don't calculate at every ticks

Anyone can give sample code to do that ?

best regards,

BornToWin
if(iVolume(NULL,PERIOD_M1,0) == 1)

{

//do what you want here, first tick of every M1 bar.

}
 

Got the key ! Any other idea ?!

Thanks for reply Michel,

I got the key.

But sometimes the volume of first tick of every M1 bar > 1

While iVolume() > 1 at the first tick, the calculation didn't done !?

Or the first tick of that M1 bar must be = 1 ?

And we can't change expression to >= 1, right ?

That will make this idea turn to useless, cause it calculate to the end of that bar live !

My idea is to calculate only at the complete of TF M1.

Any other idea ?

BornToWin

Michel:
if(iVolume(NULL,PERIOD_M1,0) == 1)

{

//do what you want here, first tick of every M1 bar.

}