molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming
http://www.molanis.com/forum/

negative value input when attaching EA
http://www.molanis.com/forum/viewtopic.php?f=6&t=1477
Page 1 of 1

Author:  RJo [ Wed Jun 06, 2012 10:21 pm ]
Post subject:  negative value input when attaching EA

I see here that double can handle negative numbers: http://book.mql4.com/basics/types. So... can I input a negative value as a MetaTrader Variable created in SB (when I attach the EA to a chart)?

This works fine when I assign the negative value directly in a TA block:

if ( ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= -0.01000 ) && (CalculateOpenPositions("AUDUSDm",OP_SELL,MagicNumberShort)<=4) )
{ SELL("AUDUSDm",S_AUDUSD_LS_4,S_AUDUSD_TP_4,S_AUDUSD_SL_4,S_AUDUSD_TS_4,"if ( ( iCustom(Symbol(),0,NzdUsdm_AudUsdm,0,0) <= -0.01000 ) && (CalculateOpenPositions(AUDUSDm,OP_SELL,MagicNumberShort)<=4) )") ;}

But the condition is ignored (EA enters all shorts immediately upon attachment to a chart) when I use a MetaTrader Variable in a TA+ block (and then input the negative value later):

if ( ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= iAC(Symbol(),0,EntryLevel5) ) && (CalculateOpenPositions("AUDUSDm",OP_SELL,MagicNumberShort)<=4) )
{ SELL("AUDUSDm",S_AUDUSD_LS_0,S_AUDUSD_TP_0,S_AUDUSD_SL_0,S_AUDUSD_TS_0,"if ( ( iCustom(Symbol(),0,NzdUsdm_AudUsdm,0,0) <= iAC(Symbol(),0,EntryLevel5) ) && (CalculateOpenPositions(AUDUSDm,OP_SELL,MagicNumberShort)<=4) )") ;}

[update: I rebuilt the imported indi in TIB to read positive and reversed my conditions in SB--same result]. Any ideas?

Author:  molanisfx [ Thu Jun 07, 2012 9:01 am ]
Post subject:  Re: negative value input when attaching EA

The 2 logics are not the same:
- ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= -0.01000 ) is not
- ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= iAC(Symbol(),0,EntryLevel5)
In a TA plus you can do ( iCustom(Symbol(),0,"NzdUsdm_AudUsdm",0,0) <= EntryLevel5)

Author:  RJo [ Thu Jun 07, 2012 9:31 am ]
Post subject:  Re: negative value input when attaching EA

:oops: I now see that I failed to select User Defined Number in the TA+ block, so the Accelerator/Decelerator Oscillator was defaulted to. Thank you.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/