How to code? - page 292

 

Indicator idea but Programming diffculty

hi

well i was doing little programing in the Mt4 its fun but i m not pro just simple editing of old indicator. Ok i want to make a simple indicator but don't know how to do it.

its simple indicator it simply check for the value if the value of the all the varible are same it draw that point where the value of the all the variable match.

my simple solution

let suppose we got variables

double movingavg1;

double movingavg12;

double movingavg13;

double movingavg14;

double movingavg15;

double movingavg16;

double movingavg17;

double movingavg18;

double movingavg19;

double movingavg10;

double movingavgall;

we declare the variable i am just giving an example i am using iStochastic(1), but we can use for any indicator.

movingavg12=iStochastic(1)

movingavg13=iStochastic(2)

.

.

.

so on

now

if (movingavg12=movingavg13=movingavg14,....) (put value in in variable "movingavgall") //put the value which is equal for vria

draw movingavgall on bars

Application

let suppose i want to check where the moving average 3 and moving average 5 have the same value

even this indicator can be used with RSI where the RSI 1 and RSI 2 value = 80

and many more

even if we add MTF that will be added bonus

looks simple in writing but i was not able to find the solution hope someone can help

hope you people understand what i am saying

thanks

 

How to code my indic in to EA ?

Please help me how to code this indic in to EA ? this indic work in to H4 or make a choice work at H4 or D1.

The rule are very simple :

If find No.3 at H4 or D1 --> Blue --> Buy --> No.3 at chart open wait untill have same direction with H4 and Buy.

If find No.3 at H4 or D1 --> Red --> Sell --> No.3 at chart open wait untill have same direction with H4 and Sell.

I only need :

extern int SL = 100; //stop loss

extern int TP = 100; //take profit

extern bool Trailing = true;

extern int TS = 10; //trailing stop

extern double Lots = 0.1;

extern int TimeStart = 7;

extern int Time Stop = 14;

int MagicNumber = 031174;

My best Regards,

Thank you for your help

Files:
paijo123.mq4  17 kb
 

Code to capture a buy signal in painted in the previous period

My code needs to capture a buy signal that the indicator occasionally paints in the previous period but I do not want to just look at that period else I shall get a double buy indication in two periods. I am relatively new to MQL4 but have written some code that I think does the job.

Could someone confirm if this is the correct way to handle this task?

bool dynamic_latch(int mode)

{

if (var_current_period==1 && var_previous_period==0) then return 1;

if (var_current_period==0 && var_previous_period==1 && dynamic_latch!==1) then return 1;

else return 0;

}

 

Help with MTF nonLagMa 7.1 by Igorad

Hi, please is there someone who knows how to add a simple NBars option in order to calculate the code only for a certain number of bars for these indicators?

I'm not able to do it with these indicators. Usually i modify the for cycle for that purpose, but with these indicators it doesn't work.

Please someone knows how i have to do?

mtf_nonlagma_v7.1.mq4

nonlagma_v7.1.mq4

thanks

 

keyboard shortut in a EA ?

Hi

Is it possible to use some keyboard shortut in a EA ? I can't find a function to do this... maybe with a DLL or something.. Did someone already try this ? I'm trying to add this to a close all order EA...

Thank you

 

How the code

mladen:
on weekly and mothly charts

Master Mladen,

May I ask, if I want to replace the code on my indicator to:

No.1

Number 1 is formed if it is found that a very strong momentum or a large candle. Or lined bullish candles or lined bearish candles .

No.2

If after a number 1 appears and until the circumstances and failed to make a new high or new low, or make a candle closing higher or lower under high candle bullish or bearish the last of the foot No.1. So the foot of No.2 is a correction of the foot No1.

No.3

At the end of the trading session, it correction it failed to form a low or a high form of lower or higher than it legs No.1, No.3 is formed.

How does it code Master Mladen ?

My best regards,

Thank You

Files:
123.jpg  61 kb
 

Boost Library Import Into Metatrader (MT4) Script File.

I am working within a Metatrader script file and need to call a function within a Boost library. Anyone know if this is possible? If so how do you configure the import?

 

Show me the Last Closed Profit

Hello,

i need the following code:

I need the Amount of the Last Closed Trade.

How can i Code it? I will make a Alert (PopUp), after a Trade has reached the TakeProfit with it.

Best regards,

halobungie

 

What is wrong with my code?

I'm trying to learn MQ4. My first simple program is supposed to pop a alert when 2 MAs cross. I can't figure out why

this code is not working.

Any help will be really appreciated! Thanks in advance.

extern int Period_MA1 = 5;

extern int Period_MA2 = 1;

double MA1;

double MA2;

int init()

{

return(0);

}

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

int deinit()

{

return(0);

}

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

int start()

{

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

MA1=iMA(NULL,0,Period_MA1,0,MODE_SMA,PRICE_CLOSE,0);

MA2=iMA(NULL,0,Period_MA2,0,MODE_SMA,PRICE_CLOSE,0);

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

if (MA2 == MA1 )

Alert("Price is the same(",Period_MA2,").");// Alert

return;

}

 

...

You can find the last closed order profit with a function like this :

double lastOrderProfit(int magicNumber=0)

{

datetime lastTime = 0;

double lastProfit = 0;

for(int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==false) break;

if (magicNumber!=0)

if (OrderMagicNumber() != magicNumber) continue;

if (OrderSymbol() != Symbol()) continue;

if (OrderCloseTime() <= lastTime) continue;

lastTime = OrderCloseTime();

lastProfit = OrderProfit()+OrderSwap()+OrderCommission();

}

return(lastProfit);

}
halobungie:
Hello,

i need the following code:

I need the Amount of the Last Closed Trade.

How can i Code it? I will make a Alert (PopUp), after a Trade has reached the TakeProfit with it.

Best regards,

halobungie
Reason: