Ask! - page 86

Sadly
433
Sadly  

Thank you Michel. Using what you've suggested A *= + A does indeed give a positive sign ie: changes -A to +A.

Sadly
433
Sadly  
Michel:
if(b1 && (b2 || b3))

{

do_something

}

Here;s what I am doing ...

if(Alarm_Reset && (stepSignalBuffer[shift] Upr_level ))

{

if(stepSignalBuffer[shift] < Lwr_level)

{

PlaySound("twank.wav");

}

else

{

PlaySound("tick.wav");

}

Alarm_Reset = false;

}

else

{

Alarm_Reset = true;

}

}

That is,ifthe alarm has been reset (to true) and either signalbuffer < lwr_level orsignalbuffer > upr_level

Play one sound if the signalbuffer is below the lower level or another sound if above the upper level. Set the alarm to false (don't want another alarm going off if it's already the done.

else

Reset the alarm (ie: signalbuffer is outside of the lower_level and the upper_level)

Unfortunately that's not what's happening but at least I know that the code is correct and it's probably down to the logic.

Thank you again Michel.

EDIT: I've just commented stepSignalBuffer[shift] and it's value is always ZERO! I feel such an idiot.

Michel
476
Michel  
Sadly:
Thank you Michel. Using what you've suggested A *= + A does indeed give a positive sign ie: changes -A to +A.

No, this is wrong, I said: A *= -1; not A *= +A;

This flipflop the sign; but if you need to have a positive number, use the MathAbs() function : A = MathAbs(A); Wathever is A , it will become positif.

BornToWin
107
BornToWin  

Weekend test code

Hi guru,

Are there any server can feed price to give us chance test our code at Saturday and Sunday ?

I mean if there possible to make simulator server to give chance to test at weekend ?

This idea come because of :

1. While at workdays, we are seriously to watch our chart,

at that time, can't seriously type code.

2. We have more time at weekend, then we can seriously test our code atm.

Maybe some one can give me information about this idea ?

Best regards,

BornToWin

Sadly
433
Sadly  
Michel:
No, this is wrong, I said: A *= -1; not A *= +A; This flipflop the sign; but if you need to have a positive number, use the MathAbs() function : A = MathAbs(A); Wathever is A , it will become positif.

I was after trying t flipflip the sign which appeared to work. I tired the MathsAbs() function too and indeed the number is positive.

Thank you Michel, you have been a great help to me.

aurorau
98
aurorau  
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.

derekz
166
derekz  

search a simple ea

hi ... i search this simple ea

daily breakout EA with trailing stop and profit lock function.

Exist?

Dave137
212
Dave137  

#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!

Giovanni
10
Giovanni  

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)

{

wolfe
1037
wolfe  

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