How to code? - page 4

 

Have code, need help making EA

I have a portion of code for a Moving Stop, but have no programming experience to make an EA out of it. Will somebody with EA creation ability kindly produce an EA with the code below?!?

total=OrdersTotal();

if(total>0){

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

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol()==Symbol()){

if(Bid-OrderOpenPrice()>=Point*15 && Bid-OrderOpenPrice()<Point*20 && OrderStopLoss()< OrderOpenPrice()-5*Point){

OrderModify(OrderTicket(),OrderOpenPrice()-Point*5,OrderTakeProfit(),Blue);

}

if(Bid-OrderOpenPrice()>=Point*20 && OrderStopLoss()< OrderOpenPrice()){

OrderModify(OrderTicket(),OrderOpenPrice(),OrderTakeProfit(),Blue);

}

}

}

}

The EA will move the Stop to -5 after moving 15 pips favorably, and move Stop to BreakEven after moving 20 pips favorably.

 
stu:
I have a portion of code for a Moving Stop, but have no programming experience to make an EA out of it. Will somebody with EA creation ability kindly produce an EA with the code below?!?
total=OrdersTotal();

if(total>0){

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

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol()==Symbol()){

if(Bid-OrderOpenPrice()>=Point*15 && Bid-OrderOpenPrice()<Point*20 && OrderStopLoss()< OrderOpenPrice()-5*Point){

OrderModify(OrderTicket(),OrderOpenPrice()-Point*5,OrderTakeProfit(),Blue);

}

if(Bid-OrderOpenPrice()>=Point*20 && OrderStopLoss()< OrderOpenPrice()){

OrderModify(OrderTicket(),OrderOpenPrice(),OrderTakeProfit(),Blue);

}

}

}

}

The EA will move the Stop to -5 after moving 15 pips favorably, and move Stop to BreakEven after moving 20 pips favorably.

stu,

Do you want to apply this technique to any EA? Or you have entry points for this EA?

I think your technique is very good one!

 

I will enter my system manually, I do not trust EA entry yet. I want to use EA ONLY for exit now. I feel EXIT strategy is equally (if not more) important than entry strategy. I do not like Trailing Stops, I have had much more success with STEPPED MOVING STOPS. I would love to have EA to do this for me because I have time to place trade but no time to monitor for exit. I like to backtest VISUALLY,, which is very slow but I have very specific entry criteria so it works well for me. I am currently reading Codergurus AWESOME lesson for BEGINNERS to programming MQ4: http://www.metatrader.info/node/59

Codersguru, if you are reading this thread, let me tell you man: You are a genius!

I still need help making this EA.

 

For example:

double lot = Lots;

int ticket = GetLastOrder(Symbol(), OP_BUY, MODE_HISTORY);

if (ticket >= 0) {

OrderSelect(ticket, SELECT_BY_TICKET, MODE_HISTORY);

if (OrderProfit() > 0) lot = 2*OrderLots();

}

int GetLastOrder(string symbol, int type, int mode) {

int cnt = -1;

if (mode == MODE_TRADES) cnt = OrdersTotal(); else

if (mode == MODE_HISTORY) cnt = HistoryTotal(); else

return(-1);

int ticket = -1;

datetime dt = 0;

for (int i=0; i < cnt; i++) {

if (!OrderSelect(i, SELECT_BY_POS, mode)) continue;

if (OrderSymbol() != symbol) continue;

if (OrderMagicNumber() != Magic) continue;

if (OrderCloseTime() > dt && OrderType() == type) {

dt = OrderCloseTime();

ticket = OrderTicket();

}

}

return(ticket);

}

 

Traders secret Code?

anyone hear any details on Traders Secret Code by Mark Mcrae?

I've heard some good reviews, but maybe it's too new to tell if it's REALLY that good.

www.traderssecretcode.com

 

I see no reason to him still making money on selling books.

 

http://www.traderssecretcode.com/

I've seen a few of his free videos he sends out as I'm on his mailing list. Nearly all of these strategies include Moving averages, basic Fibonacci retracements etc.

I don't have access to his video site though, so don't know if they are any better. I deleted the free ones I got as they were useless hindsight cherry picked trades, but if I had access to his video site I would share it.

Maybe someone here has access?

 

i'm looking for code to make my EA trade at half volume if it trades the same direction in a pair twice in a row, i.e

if i enter GBPUSD at full volume long at 1.7500, and the next signal I see is also a GBPUSD long say at 1.7530, the second trade should be half volume, as it is rejoining a move which has already been going for a while, so the risk should be lowered.

so basically i need my EA to access the record of the last closed trade on the current pair and get it's open price and whether it was a short or long position.

could the above code be modified to do something like that? i've tried to do it myself but it's all a bit advanced for me

thanks

 

thanks you.

 
Reason: