Ask! - page 78

 
Kalenzo:
Yes, Only start function is required.

Thanks for your answer Kalenzo.

 
Bongo:
Kalenzo,

I have a question:

HEDGING:

I'm looking for:

if (OrderOpenPrice() = = Bid (or Ask)

Opened price must be equal as new price.

I hedging with same pair EURUSD.

If opened price is sell and price is 1.3580,

buy price must be the same.

Thanks. Here are the codes.

B.

//------------------------------------------

if(Buy==0)

{

RefreshRates();

OrderSend(Symbol_1,OP_BUY,lotsi,MarketInfo(Symbol_ 1,MODE_ASK),...

RefreshRates();

if (OrderOpenPrice() == Bid)

{

OrderSend(Symbol_1,OP_SELL,lotsi,MarketInfo(Symbol _1,MODE_BID),...

}

This should work, however, it will be hard to make with market order, try to set up pending orders on specified levels.

 

It is not working.

EA is only buying.

If I take out,

if (OrderOpenPrice() == Bid)

after is buing and selling

but not at the same price, difference is spread.

 

code protection

I want to know why the function 'AccountNumber()' is not returning the

correct value or any value for a second or two.

int Account = 123456;

if (Account != AccountNumber())

{

Comment("You can not use this program with this account");

return (0);

}

else

{

Comment("Welcome to Program");

}

Thanks

 

int Account = 123456; //change this to yor acc number

if (Account != AccountNumber())

{

Comment("You can not use this program with this account");

return (0);

}

else

{

Comment("Welcome to Program");

}

 

Yes, it will. If you don't need to run any code at the first time you attach the EA (init) or de-attach the EA (deinit).

n7drazen:
Will the expert advisor run normally without init() and deinit() functions?
 

What do you mean?

RBK1959:
I want to know why the function 'AccountNumber()' is not returning the

correct value or any value for a second or two.

int Account = 123456;

if (Account != AccountNumber())

{

Comment("You can not use this program with this account");

return (0);

}

else

{

Comment("Welcome to Program");

}

Thanks
 

Lag

When I put on the protection with the right machine number it first says that the program is invalid with this number then a few seconds later it kicks in and says it is valid.

Thanks

Rich

 

To CodersGuru : Need help to Close Position...

To CodersGuru : Need help to Close Position.... ( 2nd post )

Hi CodersGuru,

This is the second post asking you and may be you quite busy right now.

So sorry for disturbing you for a second time. First time, I am learning is EuroX2_sl, extended from 10 points 3 EA script. After did a few forward test, this EA did Open Position okay but it did not Close Position as I need to when market reverse ( after setting indicator ). Maybe, something is wrong with the code ( cos' I am not a programmer ) and I think I need your help to solve it. Could please check which part may be wrong ?

Condition is :

1. OPEN BUY when indicator condition exist. ie: stochastic

2. CLOSE BUY when OPEN SELL indicator exist. ie:stochastic

3. OPEN SELL as the indicator condition ( no. 2 above ) exist. ie : stochastic

4. CLOSE SELL as the indicator condition ( no. 1 above ) exist. ie : stochastic

I think OPEN position is okay but the problem is with the CLOSE POSITION as it did not CLOSE ( BUY or SELL ) even when the indicator exist.

The code as I did is :

-------- part of script from EuroX2_sl extended from 10 points 3 as I think for close position -------

// it is important to enter the market correctly,

// but it is more important to exit it correctly...

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && // check for opened position

OrderSymbol()==Symbol()) // check for symbol

{

//+--------------------------------------------------------------

if(OrderType()==OP_BUY) // long position is opened

{

//+-------------------------------------------------------------------

//+ CONDITION FOR CLOSE POSITION

//+-------------------------------------------------------------------

//+--------------- CLOSE BUY POSITION ----------------------------

if ( Stoch_Main_M15_Cu < Stoch_Sig_M15_Cu )

//+------------------------------------------------------------------

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position

return(0); // exit

}

//+-----------------------------------------------------------------------

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

//+---------------CLOSE SELL POSITION --------------------------------

else // go to short position

{ //+ DO NOT REMOVE

if(OrderType()==OP_SELL) // short position is opened

{

}

// should it be closed?

//+----------------------------------------------------------------------------

if ( Stoch_Main_M15_Cu > Stoch_Sig_M15_Cu )

//+-----------------------------------------------------------------------------

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet) ; // close position

return(0); // exit

}

//+----------------------------------------

// check for trailing stop

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

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

Thank you,

fxgroup

 

Lag

codersguru:
What do you mean?

Codersguru..the code you gave us for protection. I used your code exactly on your page. What happens is "you can not use this program with this account" comes up for a few seconds before "Welcome to the program" when the right account number is in the code.

Thanks

Rich

Reason: