MagnifyHow to disable EA if spread is too wide or pip amount in MT4

1
hello mladen

i need script to disable auto trading if spread wide of x pips and enable it again if spread back to normal

i found this code on net

could you check it to see is this code correct?
regard

it script

Code: Select all

//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+#property strict
#property show_inputsextern int MaxSpread=20; //Max Spread in pipettesvoid OnStart()
 {
//---
 if(MarketInfo(Symbol(), MODE_SPREAD)<MaxSpread){
 Print("I can order");
 }
 else{
 Print("Cannot order, spread is too high");
 }
 }
//+------------------------------------------------------------------+
what we want: 1+1+1+1+1+1+1+1+1=9 <3
what market delivers: 1+2+8+7-4+0-5+8-4-5+1=9 :problem:


Re: How to disable EA if spread is too wide or pip amount in MT4

2
bilbao wrote:hello mladen

i need script to disable auto trading if spread wide of x pips and enable it again if spread back to normal

i found this code on net

could you check it to see is this code correct?
regard

it script

Code: Select all

//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+#property strict
#property show_inputsextern int MaxSpread=20; //Max Spread in pipettesvoid OnStart()
 {
//---
 if(MarketInfo(Symbol(), MODE_SPREAD)<MaxSpread){
 Print("I can order");
 }
 else{
 Print("Cannot order, spread is too high");
 }
 }
//+------------------------------------------------------------------+
It is correct

Re: How to disable EA if spread is too wide or pip amount in MT4

4
mladen wrote: Sun Apr 09, 2017 6:56 am Or this can be used (but this disables all experts from trading if the spread on the current chart is higher that the desired)
It also re-enables them if the spread becomes less than the maximal spread allowed
_________________________

PS: that is an indicator (not an EA - for obvious reasons )
mlade:

could you put this rule to indicator:

if last candle {not current} spread wide of x pip auto trading disable and when last candle {not current} spread be less than x pip auto trading enable

because on news, spread always start from 0 pip and auto trading always disable/enable especially on major news this story can happen on next 10_20 candle and ea take loss position, but when indicator work on last candle we have few loss trade,because we have more chance
for disable auto trading on crazy tick and spread
regard

Re: How to disable EA if spread is too wide or pip amount in MT4

5
bilbao wrote: Fri Apr 14, 2017 4:26 am mlade:

could you put this rule to indicator:

if last candle {not current} spread wide of x pip auto trading disable and when last candle {not current} spread be less than x pip auto trading enable

because on news, spread always start from 0 pip and auto trading always disable/enable especially on major news this story can happen on next 10_20 candle and ea take loss position, but when indicator work on last candle we have few loss trade,because we have more chance
for disable auto trading on crazy tick and spread
regard
bilbao

Sorry, but in metatrader 4 we do not have a historical spread. I can not know what was the spread at the last tick of the previous (or any other closed) candle


Re: How to disable EA if spread is too wide or pip amount in MT4

7
Hi Mladen tried to download this indicator but its giving me error message " The selected attachment does not exist anymore. "


mladen wrote: Sun Apr 09, 2017 6:56 am Or this can be used (but this disables all experts from trading if the spread on the current chart is higher that the desired)
It also re-enables them if the spread becomes less than the maximal spread allowed
_________________________

PS: that is an indicator (not an EA - for obvious reasons )


Who is online

Users browsing this forum: Google [Bot] and 10 guests