How to code? - page 192

 

...

Deleted by mladen

Reason : no point in showing what can go wrong

 

Thanks

Thanks....... Roger

 

need code help..

thank you guys...

 

Help please

HELLO EVERYONE,

Can someone please help make this indicator not to repaint past history especially if the bar has been closed,the indicator repaints sometimes 2 to 3 bars in live trading after candles have been closed and if possible an alert be added to it.thanks in anticipation.

 

need code help..

Hello fellow members,

I'm not a programmer, but I would really appreciate if someone can help me with this issue.

How do I rewrite this code so it would do the following;

if (Total Open Order = 0)

then

lot = Type1Lot(order_type);

if (Total Open Order = 1)

then

lot = Type2Lot(order_type);

if (Total Open Order > 2)

then

lot = Type3Lot(order_type);

Thanks all.

Appreciate

 

Is there a better way to code

I have coded an indi that puts swing highs/lows on the chart and I need to know the last of each of these before continuing. This is my attempt at looking for these two prices (hence I need some help).

Most of the times this works, but today it was saying the last swing high was actually the second last swing high.

Could someone please look at this and see if there is a better way of coding this part?

Thanks for any help.

int highbar,lowbar,i,n;

double curlow=0,curhigh=0;

for (i=200;i>=1;i--)

{

if (High<High && High<High && High && High<High)

{

curhigh=High;

highbar=i+2;

}

if (Low>Low && Low>Low && Low>Low && Low>Low)

{

curlow=Low;

lowbar=i+2;

}

}

//----check if there is higher/lower candle since last fractal----------

n=MathMax(highbar,lowbar );

for (int x=n-1;x>=0;x--)

{

if (High[x]> curhigh)

{

curhigh=High[x];

highbar=x;

}

if (Low[x]< curlow)

{

curlow=Low[x];

lowbar=x;

}

}

It looks like the indents didn't paste properly, sorry.

 
forexarchitect:
Hello fellow members,

I'm not a programmer, but I would really appreciate if someone can help me with this issue.

How do I rewrite this code so it would do the following;

if (Total Open Order = 0)

then

lot = Type1Lot(order_type);

if (Total Open Order = 1)

then

lot = Type2Lot(order_type);

if (Total Open Order > 2)

then

lot = Type3Lot(order_type);

Thanks all.

Appreciate

I am by no means an expert coder but I think you need to loop through all your orders and count which orders meet your specs. Then use different if statement for different order types.. example.

int total=OrdersTotal(),totalBuy,totalSell;

for (int q=0; q<total; q++ )

{

OrderSelect(q,SELECT_BY_TICKET,MODE_TRADES);

if (OrderMagicNumber() == Magic && OrderType() == OP_BUY)

totalBuy++;

else if (OrderMagicNumber() == Magic && OrderType() == OP_SELL)

totalSell++;

}

Here I am selecting which tickets to count by Magic number, and also counting the number of Short, and number of long. You can use the above code as an example.

 

Place limit order on 50 and 100 psych levels

Hey, I was looking for a little help with my code. Would this be the code to use in order to place a market limit order at the 50 and 100 round levels of a currency pair. I want to place an order at the 50 and 100 levels above and below the current Ask/Bid.

if (Point == 0.00001) Poin = 0.0001; //6 digits

else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)

else Poin = Point; //Normal

for(double q=Ask*Poin,q<Ask+100*Poin,q++)

{

if(MathMod(q,100) == 0 || MathMod(q,50) == 0)

{

\\ Place limit order

}

for(double q=Bid*Poin,q>Bid-100*Poin,q--)

{

if(MathMod(q,100) == 0 || MathMod(q,50) == 0)

{

\\ Place limit order

}

Any help would be appreciated.

 

Bar color indicator

Hi, can please someone help with an MT4 indicator?

Not sure if it can be done but need the bars to be re-colored.

R1 = lowest value for the past 20 bars + (2*ATR(10))

R2 = highest value for the past 20 bars - (2*ATR(10))

If closing price is greater than R1 then color the bar as.... a bright blue.

If closing price of the previous bar is less than R2 then colour the bar as.... FireBrick

Thanks

A

 

still looking for code example of EA opening more than 1 order

I only want to open 2 orders at a time, 1 with tp and 1 without and then NEVER open another in that direction until conditions change to open in opposite. then close all and repeat in opposite.

I'm trying hard to code it but...FAIL so far.

Biggest problems are 1 position opens at close of candle stick...then 2nd opens at close of NEXT candle stick. I also get More than 2 open positions sometimes and I get a new position every time 1st hits TP. ALL VERY BAD.

here's the buy order code and sell is basically the same...

ANY TIPS would be helpful, i'm willing to type up the code

Even an EA that does this that I can look at for examples..

I think this idea is very important and should be incorporated into ALOT of various EA's for money management purposes.

THANKS A TON

if ( ) {

Closebuy = True;

MAcrossDown = True;

MAcrossUP= False;

OrdertotalCloseBuy = OrdersTotal();

int AttemptsTriedCloseBuy = 0;

bool OrderCloseBuy = False;

bool PositionClosedBuy = False;

if(OrdersTotal() > 0 ){

OrderSelect(0, SELECT_BY_POS, MODE_TRADES);

if(OrderType() == OP_BUY){

for (int i = OrdertotalCloseBuy-1; i >= 0; i --) {

PositionClosedBuy = False;

AttemptsTriedCloseBuy = 0;

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

while (!PositionClosedBuy && AttemptsTriedCloseBuy < CloseposnAttempts) {

AttemptsTriedCloseBuy = AttemptsTriedCloseBuy + 1;

OrderCloseBuy = OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, LimeGreen);

Sleep(PausebetweenOrders * 1000);

if(OrderCloseBuy == True) { // Position Closed Successful.

PositionClosedBuy = True;

// if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");

} else if( Order == False && AttemptsTried >= CloseposnAttempts ) {

Print( AttemptsTried + " attempts to close Market order " +

OrderTicket() + " failed. Error [ " + GetLastError() + " ]" );

// if (SignalMail) SendMail( AttemptsTried, " attempts to close Buy Market order Failed" );

} // End If, Order:

} // End While Loop, AccountAvailable:

}//for

}//if ordertype

}//if orderstotal

Sleep(1000);

if(OrdersTotal() == 0 && Closebuy == True && Sell_Complete_Wait4Cross_Up == False) {

SellTicket1 = False;

SellTicket1 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLoss, Bid - TakeProfit * Point, "SELL(#" + MagicNumber + ")", MagicNumber, 0, Red);

Sleep(PausebetweenOrders * 1000);

Sell_Complete_Wait4Cross_Up = True;

Buy_Complete_Wait4Cross_Down = False;

if (Ticket && SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open 1st Sell");

Sleep(1000);

SellTicket2 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLoss, 0, "2nd SELL(#" + MagicNumber + ")", MagicNumber, 0, Pink);

Sleep(PausebetweenOrders * 1000);

if (Ticket2 && SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open 2nd Sell");

if(OrdersTotal() == 2 && MAcrossDown == True) {Sell_Complete_Wait4Cross_Up = True; Buy_Complete_Wait4Cross_Down = False;}

}//Ordersend

} //Closebuy