You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Prevent overtrading
Hello all,
I have tested my EA using all ticks method on a H4 chart using a MACD cross to initiate orders (amongst others) and the strategy tester opens about 200 positions in the first few minutes so after doing some reading I realise that I need to limit the number of trades it places, on my system it shouldnt place more than 1 trade every 4 hours because I wait for the candle to close before hand using iMACD(... PRICE_CLOSE...) and offset this for 0 for MACDMainCurrent & MACDSymbolCurrent and 1 for MACDMainPrevious & MACDSymbolPrevious.
My global variables are:
string hasOrderedGV = "has_ordered_GV";
string barsGV = "bars_GV";
And I have inserted this code before my EA checks for long or short positions:
//--- Determine if order already placed on H4 time block
if ((GlobalVariableGet (barsGV) == 0) || (GlobalVariableGet (barsGV) < Bars))
{
GlobalVariableSet(hasOrderedGV,false);
GlobalVariableSet(barsGV,Bars);
}
//--- Check for long position (BUY) possibility
if (GlobalVariableGet (hasOrderedGV, false))
{
if ... (this is where I actually check MACD cross amongst other indicators).
Then if the order opened successfully:
if (Ticket > 0)
{
GlobalVariableSet(hasOrderedGV,true);
{
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES))
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), GetTPPriceShort(SLPriceShort, RiskRewardRatio), OrderExpiration(), Green);
etc etc.
Can someone tell me if I am going about this the right way? I didnt know whether there may have been a more efficient or accurate way of doing it? Thanks.
...
Why don't you simply count how many orders your EA has already opened and if it has opened an order already, do not open a new order?
Just an idea (and a usual and the simplest way how the number of orders opened by an EA is limited)
Hello all,
I have tested my EA using all ticks method on a H4 chart using a MACD cross to initiate orders (amongst others) and the strategy tester opens about 200 positions in the first few minutes so after doing some reading I realise that I need to limit the number of trades it places, on my system it shouldnt place more than 1 trade every 4 hours because I wait for the candle to close before hand using iMACD(... PRICE_CLOSE...) and offset this for 0 for MACDMainCurrent & MACDSymbolCurrent and 1 for MACDMainPrevious & MACDSymbolPrevious.
My global variables are:
string hasOrderedGV = "has_ordered_GV";
string barsGV = "bars_GV";
And I have inserted this code before my EA checks for long or short positions:
//--- Determine if order already placed on H4 time block
if ((GlobalVariableGet (barsGV) == 0) || (GlobalVariableGet (barsGV) < Bars))
{
GlobalVariableSet(hasOrderedGV,false);
GlobalVariableSet(barsGV,Bars);
}
//--- Check for long position (BUY) possibility
if (GlobalVariableGet (hasOrderedGV, false))
{
if ... (this is where I actually check MACD cross amongst other indicators).
Then if the order opened successfully:
if (Ticket > 0)
{
GlobalVariableSet(hasOrderedGV,true);
{
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES))
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), GetTPPriceShort(SLPriceShort, RiskRewardRatio), OrderExpiration(), Green);
etc etc.
Can someone tell me if I am going about this the right way? I didnt know whether there may have been a more efficient or accurate way of doing it? Thanks.Just because my EA typically has several positions open at one time; so I couldnt use say,
if (CountedOrders > 5)
Break;
Or something of the sort, because I dont know how many positions will be open at any point in time. I need to relate it to time i'm thinking.
I m attach this EA to my 5 digit mt4 account.. But it doesn't open any trade....
pls help me
Pls i need to edit dis ea to move stoploss in 3 steps
this EA has a breakeven ability already but i want this EA to move my
stoploss from its first breakeven point to another +20 pips once my profit gets to
+27pips and move it again to +40pips when it gets to +50pips and even
more if possible.
Hi Mladen,
Thanks for the heads up! I managed to solve it already.
By the way, do you know what does MODE and SHIFT function in iStochasticdo or is there any place that provides more information? I have being reading the documentation on the mql4 website but yet it does not make sense to me. The explanation they provide is too brief.
E.g.
iStochastic(NULL, 0, 3, 3, 3, MODE_SMMA, 0, MODE_SIGNAL, Current + 0);
iStochastic(NULL, 0, 5, 3, 3, MODE_SMMA, 0, MODE_MAIN, 0);
iStochastic(NULL, 0, 5, 3, 3, MODE_SMMA, 0, MODE_SIGNAL,Current + 1);
What does the current + 0 etc do?
Thanks and regards
Terrance
Terrance That is a function. Post it at the end of your EA and place calls to it where you think it is appropriate to check if an order is already opened at a current bar
Hi would someone be able to tell me where I am going wrong here please? I am getting error code ')' wrong parameters count on the line highlighted in red - but all the parameters add up...
if ((GlobalVariableGet (barsGV) == 0) || (GlobalVariableGet (barsGV) < Bars))
{
GlobalVariableSet(hasOrderedGV,false);
GlobalVariableSet(barsGV,Bars);
}
//--- Check for long position (BUY) possibility
if (GlobalVariableGet (hasOrderedGV, false))Thanks
...
Terrance
MODE_MAIN means you are reading in the value of the stochastic line. MODE_SIGNAL means you are reading in the value of the stochastic signal line.
As of SHIFT : it is the same for every indccator (even the custom ones). As an example : SHIFT=0 means current bars value, SHIFT=1 means the first closed bars value and so on ...
Hi Mladen,
Thanks for the heads up! I managed to solve it already.
By the way, do you know what does MODE and SHIFT function in iStochasticdo or is there any place that provides more information? I have being reading the documentation on the mql4 website but yet it does not make sense to me. The explanation they provide is too brief.
E.g.
iStochastic(NULL, 0, 3, 3, 3, MODE_SMMA, 0, MODE_SIGNAL, Current + 0);
iStochastic(NULL, 0, 5, 3, 3, MODE_SMMA, 0, MODE_MAIN, 0);
iStochastic(NULL, 0, 5, 3, 3, MODE_SMMA, 0, MODE_SIGNAL,Current + 1);
What does the current + 0 etc do?
Thanks and regards
Terrance...
The error is that GlobalVariableGet() has only one parameter (the variable name). You do not need the second parameter (the "false" that you have in the call to the function)
Hi would someone be able to tell me where I am going wrong here please? I am getting error code ')' wrong parameters count on the line highlighted in red - but all the parameters add up...
if ((GlobalVariableGet (barsGV) == 0) || (GlobalVariableGet (barsGV) < Bars))
{
GlobalVariableSet(hasOrderedGV,false);
GlobalVariableSet(barsGV,Bars);
}
//--- Check for long position (BUY) possibility
if (GlobalVariableGet (hasOrderedGV, false))ThanksI've changed the code to this, and its error free at least - is it OK?
if (GlobalVariableGet (hasOrderedGV) == false)