Ask! - page 16

 

a couple more problems

1. one of the things i noticed in the results were that if a trade was opened, it didn't open another one until the previous trade is complete, do you have any way to change that? make overlapping trades?

(please post a second file with the overlapping trades if you can, i still need to test both of them)

2. simple question,

if the tester doesn't show results when you input a starting balance of 500 or 1000, but it does on 3,000 or higher, what exactly does that mean, (does it mean you go bankrupt on the trades with that low of a starting balance?)

 

How do you get out of the loop?!

I have been adding some of my own alerts and finally got some success, but many times I get myself it anever ending alert loop and the only way to break it is to force MT4 to close, how can I put a break in there, or is there a keyboard break I can use?

than ks for any help with my basic questions

 

Could/would you show me this...

programming still confuses me...

I wonder if you could walk me thru something very basic and show me how the code should be to make this happen...

two moving averages cross...it enters one order with a trailing stop...

//---- input parameters

extern double lots=1.0;

extern int MA1=1;

extern int MA2=5;

extern int trailingstop=8;

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

//| expert initialization function |

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

int init()

{

//----

//----

return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| expert start function |

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

int start()

{

//----

//----

return(0);

}

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

I used this utility and created this....

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

//| This MQL is generated by Expert Advisor Builder |

//| http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ |

//| |

//| In no event will author be liable for any damages whatsoever. |

//| Use at your own risk. |

//| |

//| Please do not remove this header. |

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

#property copyright "Expert Advisor Builder"

#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"

extern int MagicNumber = 0;

extern bool SignalMail = False;

extern bool EachTickMode = False;

extern double Lots = 1.0;

extern int Slippage = 0;

extern bool StopLossMode = False;

extern int StopLoss = 10;

extern bool TakeProfitMode = False;

extern int TakeProfit = 8;

extern bool TrailingStopMode = True;

extern int TrailingStop = 10;

#define SIGNAL_NONE 0

#define SIGNAL_BUY 1

#define SIGNAL_SELL 2

#define SIGNAL_CLOSEBUY 3

#define SIGNAL_CLOSESELL 4

int BarCount;

int Current;

bool TickCheck = False;

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

//| expert initialization function |

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

int init() {

BarCount = Bars;

if (EachTickMode) Current = 0; else Current = 1;

return(0);

}

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

//| expert deinitialization function |

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

int deinit() {

return(0);

}

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

//| expert start function |

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

int start() {

int Order = SIGNAL_NONE;

int Total, Ticket;

double StopLossLevel, TakeProfitLevel;

if (EachTickMode && Bars != BarCount) TickCheck = False;

Total = OrdersTotal();

Order = SIGNAL_NONE;

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

//| Variable Begin |

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

double Buy1_1 = iClose("EURUSD", PERIOD_M1, Current + 0);

double Buy1_2 = iMA("EURUSD", PERIOD_M1, 5, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Sell1_1 = iClose("EURUSD", PERIOD_M1, Current + 0);

double Sell1_2 = iMA("EURUSD", PERIOD_M1, 5, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

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

//| Variable End |

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

//Check position

bool IsTrade = False;

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

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {

IsTrade = True;

if(OrderType() == OP_BUY) {

//Close

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

//| Signal Begin(Exit Buy) |

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

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

//| Signal End(Exit Buy) |

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

if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);

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

if (!EachTickMode) BarCount = Bars;

IsTrade = False;

continue;

}

//Trailing stop

if(TrailingStopMode && TrailingStop > 0) {

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

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

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

if (!EachTickMode) BarCount = Bars;

continue;

}

}

}

} else {

//Close

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

//| Signal Begin(Exit Sell) |

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

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

//| Signal End(Exit Sell) |

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

if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);

if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");

if (!EachTickMode) BarCount = Bars;

IsTrade = False;

continue;

}

//Trailing stop

if(TrailingStopMode && TrailingStop > 0) {

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

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

OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);

if (!EachTickMode) BarCount = Bars;

continue;

}

}

}

}

}

}

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

//| Signal Begin(Entry) |

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

if (Buy1_1 > Buy1_2) Order = SIGNAL_BUY;

if (Sell1_1 < Sell1_2) Order = SIGNAL_SELL;

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

//| Signal End |

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

//Buy

if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

if(!IsTrade) {

//Check free margin

if (AccountFreeMargin() < (1000 * Lots)) {

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

if (StopLossMode) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;

if (TakeProfitMode) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);

if(Ticket > 0) {

if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {

Print("BUY order opened : ", OrderOpenPrice());

if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");

} else {

Print("Error opening BUY order : ", GetLastError());

}

}

if (EachTickMode) TickCheck = True;

if (!EachTickMode) BarCount = Bars;

return(0);

}

}

//Sell

if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

if(!IsTrade) {

//Check free margin

if (AccountFreeMargin() < (1000 * Lots)) {

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

if (StopLossMode) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;

if (TakeProfitMode) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);

if(Ticket > 0) {

if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {

Print("SELL order opened : ", OrderOpenPrice());

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

} else {

Print("Error opening SELL order : ", GetLastError());

}

}

if (EachTickMode) TickCheck = True;

if (!EachTickMode) BarCount = Bars;

return(0);

}

}

if (!EachTickMode) BarCount = Bars;

return(0);

}

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

trouble is that when it runs in the strategy tester it's doesn't give any results.

 

Oh, i figured it out! thanks so much for your tutorial

 
skorcht:
i have two simple questions i think..

how can i make the heiken ashi Candles be thickness of 5 by default instead of 3? everytime i bring up a new chart they go back to 3.

Also, how can i make a mark above or below the candle depending on value of an RSI indicator?

I understand some about programming but don't know the syntax of this...so act like i know nothing

Thanks SO much..if i discover something, i'll post it

PS that expert advisor builder is NICE, is there and INDICATOR builder too? that would be amazing

I only fixed it the Heiken Ashi.

Files:
 

New - Questions - Need Help

I am new to this forum. I would like to know if someone can give me any information as to the value of the Elite Section (other than the sales pitch with virtually no information on the link above).

I also tried to submit a question from the webpage that the link above took me to but the form keeps showing that one of the fields is blank. That field is the Priority field and there isn't anything in the drop down box (it's all blank) and there is no way for me to have a value in that field. So, I can't submit any questions in that manner.

DD

 

Has anybody else experienced this? I'm backtesting my system using alpari data, I would get error 4107 invalid price and 131 invalid volume. The 4107 was generated because the price that it gets is like 4 decimal digits more than the currency pair. I'm surprised that I get 4107 since the price I pass to OrderSend() is the predefined Bid and Ask. Also I added a Comment(Bid, " ", Ask); before the OrderSend() to see what Bid and Ask were returning. And on the Comment() it was the proper decimal precision, however OrderSend() would still generate the error. I ended up assigning the value of Bid/Ask to a variable and using NormalizeDouble() on the variable then pass it to OrderSend() and this works.

However, I still get the 131 and don't know of a workaround to that.

PipChick, personally I don't think it's worth it getting into the elite section.

 

Newbie.

I know some c++ but I am struggling with some very basic code.

What I want:

The price is 1.2788. If it moves up to 10 pips I want to buy. If it moves down 10 pips I want to sell.

Do I have the right code?

OrderSend(Symbol(),OP_BUYSTOP,1,Ask+10*Point,slippage,

(Ask+10*Point)-10*Point,

( Ask+10*Point)+200*Point,”My order comment”,0,0,Green);

OrderSend(Symbol(),OP_SELLSTOP,1,Bid-10*Point,slippage,

(Bid-10*Point)+10*Point,

(Bid -10*Point)-200*Point,”My order comment”,0,0,Green);

I have been reading http://www.metatrader.info/node/34 but im lost. Thanks for your patience.

 

Hi,

My problem: MT3,

It is not working. Why?

Thanks, Bongo

sell=false;

buy=false;

if ((C[1]>O[1])<O[0]) then { buy=true; sell=false; }

if ((C[1]O[0]) then { sell=true; buy=false; }