How to code? - page 204

 

MT-4, please help me.

MT-4- Please help me, I want make a file intersection DMI + and DMI - .I want have the signal in moment of move DMI+ and DMI- without ADX. I do care about it. I write this below but please create for this the file to move it to MF4.

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

//| ADXcross EXPERT |

//| Perky_z |

//| |

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

#property copyright "Perky_z@yahoo.com "

#property link "http://groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/"

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

//| Alerts in hand with ADXcrosses Indicator they dont need to be run together |

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

// Alerts on cross of + and - DI lines

// I use it on 15 min charts

// though looks good on any time frame

// use other indicators to confirm this trigger tho

//---- input parameters

double b4plusdi,b4minusdi,nowplusdi,nowminusdi;

//----

//---- indicators

In this part of code change period how You want (14 change for 4 in every line) and this should to work in this scal which You situate the diagram.

b4plusdi=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,1);

nowplusdi=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,0);

b4minusdi=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,1);

nowminusdi=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,0);

 

This is closing partial lots BUT...not exactly doing what I expected.

I can't figure out what it IS doing but seems to close 1 lot when price is NOT where i want it to.

Maybe you can see the issue here.

should close 1 lot when there is a BUY and the price goes .00071(just a random number i'm testing on a 1 minute chart)

or close 1 lot when there is a SELL and price goes .00071 down

using a 5 digit broker by the way. There is only 1 trade ever open and only by this EA, so no scrolling through orders

THANKS for HELP!

if (IsConnected() && IsTradeAllowed()) while (IsTradeContextBusy()) Sleep(75);

if (OrdersTotal()>0) {OrderSelect(0, SELECT_BY_POS,MODE_TRADES);

RefreshRates();

if (Bid >= (OrderOpenPrice()+ (.00071)) && OrderLots() == 2 && (OrderType() == OP_BUY)) {

OrderClose(OrderTicket(),1,Ask,10,R ed); }

if (Ask <= (OrderOpenPrice()- (.00071)) && OrderLots() == 2 && (OrderType() == OP_SELL)) {

OrderClose(OrderTicket(),1,Bid,10,B lue); }}

 

Is it possible to make a code to close a transaction at breakeven (profit=0), when a transaction has (once) have positive profit, but still below the broker's stoplevel (trailing is not touched yet)?

For a 10Point StopLevel broker, trailing system can only work if the profit has reached at least 10 Point.

Many times I see a transaction has gone positive only to 5 or 8 pips, then goes back to hit it's SL.

So I'm thinking about this, but don't know how to do it.

How to make a breakeven code for an EA, something like Trailing Stop, but works below minimum broker's StopLevel?

 

To SPACECHIMP

When we open order, we use Ask for Buy and Bid for Sell. When close - opposite.

 

Ya I think it is very useful

FulltimeTrader:June2009

 

I need help to add email alert in this Top Trend indicator

I need help to add email alert in this Top Trend indicator.

here is the line and attached file.

if (trend>0)

{

if (Signal>0 && UpTrendBuffer[shift+1]==-1.0)

{

UpTrendSignal[shift]=bsmin[shift];

UpTrendBuffer[shift]=bsmin[shift];

if(Line>0) UpTrendLine[shift]=bsmin[shift];

if (SoundON==true && shift==0 && !TurnedUp)

{

Alert("BBands going Up on ",Symbol(),"-",Period());

TurnedUp = true;

TurnedDown = false;

}

}

else

{

UpTrendBuffer[shift]=bsmin[shift];

if(Line>0) UpTrendLine[shift]=bsmin[shift];

UpTrendSignal[shift]=-1;

}

if (Signal==2) UpTrendBuffer[shift]=0;

DownTrendSignal[shift]=-1;

DownTrendBuffer[shift]=-1.0;

DownTrendLine[shift]=EMPTY_VALUE;

}

if (trend<0)

{

if (Signal>0 && DownTrendBuffer[shift+1]==-1.0)

{

DownTrendSignal[shift]=bsmax[shift];

DownTrendBuffer[shift]=bsmax[shift];

if(Line>0) DownTrendLine[shift]=bsmax[shift];

if (SoundON==true && shift==0 && !TurnedDown)

{

Alert("BBands going Down on ",Symbol(),"-",Period());

TurnedDown = true;

TurnedUp = false;

}

}

else

{

DownTrendBuffer[shift]=bsmax[shift];

if(Line>0)DownTrendLine[shift]=bsmax[shift];

DownTrendSignal[shift]=-1;

}

if (Signal==2) DownTrendBuffer[shift]=0;

UpTrendSignal[shift]=-1;

UpTrendBuffer[shift]=-1.0;

UpTrendLine[shift]=EMPTY_VALUE;

}

}

return(0);

}

Files:
toptrend.mq4  6 kb
 

Can't see the problem HERE!!!?? AAAAHHHH

I have no idea what i'm doing wrong..

this doesn't seem to close half at a certain TP

if (OrdersTotal()>0) {

OrderSelect(0, SELECT_BY_POS,MODE_TRADES);

Tick = OrderTicket(); // Number of selected order

Tip =OrderType(); // Type of selected order

Price =OrderOpenPrice(); // Price of selected order

Lot =OrderLots();

if (Bid >= (Price + (TakeProfit * Point)) && Lot == 2 && (Tip == OP_BUY)) {

OrderClose(Tick,1,Bid,10,Red); }

if (Ask <= (Price - (TakeProfit * Point)) && Lot == 2 && (Tip == OP_SELL)) {

OrderClose(Tick,1,Ask,10,Blue); }}

Do I have the BID and ASK correct? probably not

 

i need some help with my ea

i need a code to restrict my ea to only one trade. its a scalper, i only want one trade, after it makes, i put it off and attach it again the next day. can anyone help me on this??

 

Where in this thread....

Somewhere in this thread this question had to have been asked...

Can someone help me with the code to 1) have a hidden SL that 2) only closes part (50%) of the open order and 3) closes the remainder of the order after it crosses a moving average.

Attached is an EA, but it's not in English, so I can't fully understand what it is doing or where to add my other code.

Thank you for your help.

Files:
 

How to Prevent Reloading Indicator at Every New Tic

Please tell me what I did wrong invoking iCustom that causes an indicator to load again with each new tic. (Backtesting fills the whole viewing window with hundreds of iterations of that indicator.)

From my "Start Program" I want to confirm a trade opportunity using EntryDir() method (which follows):

static datetime lastsd;

if ( CurTime()-lastsd>2*60*Period() )

{

if(ZZ>=High[1] && EntryDir()==OP_SELL)

{

if(pos == 1) {DoExit(OP_BUY);}

PrepNewOrder(OP_SELL);

lastsd=CurTime();

}

if(ZZ!=0 && ZZ<=Low[1] && EntryDir()==OP_BUY)

{

if(pos == -1) {DoExit(OP_SELL);}

PrepNewOrder(OP_BUY);

lastsd=CurTime();

}

}

int EntryDir()

{

bool buyOK=false, sellOK=false;

double flow = iCustom(NULL, 0, "Dtron", 0,0) + iCustom(NULL, 0, "Dtron" 1,0);

double trigger = iCustom(NULL, 0, "Dtron", 1,0) + iCustom(NULL, 0, "Dtron", 3,0);

double reversal = iCustom(NULL, 0, "Dtron", 4,0);

if((reversal==0 && flow + trigger>0) || reversal>0) entryDir=OP_BUY;

if((reversal==0 && flow + trigger<0) || reversal<0) entryDir=OP_SELL;

return(entryDir);

}

Please show me how to prevent causing hundreds of Dtron indicator windows from opening here.

Reason: