no trade zone code - need help

 

Hello ,

Can anyone correct this code I'm trying to add.

The idea is to create a none trading zone between zone 1 and zone 2

is this a correct approach?

if (Zone2*Point<= (Bid-OrderOpenPrice() >= Zone1*Point)) return (false);

Thanks guys..

 

if (Zone2*Point<= (Bid-OrderOpenPrice() >= Zone1*Point)) return (false);

---------------

double Zone1 = 25;

double Zone2 = 50;

if( (Bid - OrderOpenPrice()) > Zone1*Point && (Bid - OrderOpenPrice()) < Zone2*Point ) return(false);

 
phy:

if (Zone2*Point<= (Bid-OrderOpenPrice() >= Zone1*Point)) return (false);

---------------

double Zone1 = 25;

double Zone2 = 50;

if( (Bid - OrderOpenPrice()) > Zone1*Point && (Bid - OrderOpenPrice()) < Zone2*Point ) return(false);


Thank you very much mr..

however, I still couldn't get it right.. if you dont mind can you have a look at this.. appreciate..

The idea is to stop the next trade if the price range is in the same zone as the previous trade. Long trade will check zone for LAST OPEN POSITION long trade, and short trade will check zone for LAST OPEN POSITION short trade.

ie. if the first LONG at 1.4000, then the second LONG will only trigger if the price move out of the zone less than 1.3990 && more than 1.4010

//+------------------------------------------------------------------------------------------------------------------------+
//| Filter for sideways market - preventing multiple trade in similar price range and create no-trade zone |
//+------------------------------------------------------------------------------------------------------------------------+

extern int Zone1 = -10; // (lower zone)
extern int Zone2 = 10; // (upper zone)

// no trade zone between -10 and +10 from the previous trade


bool CheckZone(int type)
{
int cnt = OrdersTotal();
for (int i=0; i < cnt; i++)
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;

if (OrderType() != type) continue;

if (type == OP_BUY)
{
if( (Bid - OrderOpenPrice()) > Zone1*Point && (Bid - OrderOpenPrice()) < Zone2*Point ) return(false);
}

if (type == OP_SELL)
{
if( (OrderOpenPrice()-Ask) > Zone1*Point && (OrderOpenPrice()-Ask) < Zone2*Point ) return(false);

}
}

return (true);
}

 

if( Bid > OrderOpenPrice + Zone1* Point() && Bid < OrderOpenPrice + Zone2* Point() ) return(false);

if( Ask > OrderOpenPrice + Zone1* Point() && Ask < OrderOpenPrice + Zone2* Point() ) return(false);

What is this supposed to do?

if (OrderType() != type) continue;


 
phy:

if( Bid > OrderOpenPrice + Zone1* Point() && Bid < OrderOpenPrice + Zone2* Point() ) return(false);

if( Ask > OrderOpenPrice + Zone1* Point() && Ask < OrderOpenPrice + Zone2* Point() ) return(false);

What is this supposed to do?

if (OrderType() != type) continue;



Hi Phy

The idea is to create a none-trading zone, to prevent repetitive trades on similar price range.

I'm using MA cross to enter my trade, and usually during sideways, there are plenty of crossed without any significant prive movement.

My ealier code worked only to prevent trades if the price is below OR above my zone line, but not WITHIN the zone line.

This is my problem;

if (Bid-OrderOpenPrice() >= LowerZone*Point) return (false); << THIS ONE WORKED OK

if (Bid-OrderOpenPrice() <= UpperZone*Point) ) return (false); << THIS ONE WORKED OK

BUT ONCE I COMBINE BOTH TO CREATE THE ZONE, IT DIDN'T WORK

if ( (Bid-OrderOpenPrice() >= LowerZone*Point) && (Bid-OrderOpenPrice() <= UpperZone*Point) ) return (false); << THIS DIDN'T WORK.

Attached the code again.

Thanks :)

/+-------------------------------------------------------------------------------------------------------------------------+
//| CheckMaxPips - Filter for sideways market - preventing multiple trade in similar price range and create none-trade zone |
//| This filter check for last open trade, and create upper & lower zone. No new trade will be open if price is within zone |
//+-------------------------------------------------------------------------------------------------------------------------+

extern int UpperZone = 10;
extern int LowerZone = -10;


bool CheckZone(int type)
{
int cnt = OrdersTotal();
for (int i=0; i < cnt; i++)
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;

if (OrderType() != type) continue;

if (type == OP_BUY)
{
if ( (Bid-OrderOpenPrice() >= LowerZone*Point) && (Bid-OrderOpenPrice() <= UpperZone*Point) ) return (false);
}

if (type == OP_SELL)
{
if ( (OrderOpenPrice()-Ask >= LowerZone*Point) && (OrderOpenPrice()-Ask <= UpperZone*Point) ) return (false);
}
}

return (true);
}

 

Good luck.

 
nash15 wrote >>

Hello,

Can anyone correct this code I'm trying to add.

The idea is to create a none trading zone between zone 1 and zone 2

is this a correct approach?

if (Zone2*Point<= (Bid-OrderOpenPrice() >= Zone1*Point)) return (false);

Thanks guys..

 
does anyone have a solution to this problem..I am new to coding and would like to avoid sideway movements using the MA expert
Reason: