please help and tell me why my EA does not place buy's
Files:
rsimacrossv2.mq4
10 kb
- Ea dont buy or sell
- help fineturn EA
- Ea dont buy or sell
if (EachTickMode && Bars != BarCount) TickCheck = False;Once you reach maximum bars in chart, Bars will not change. Use:
bool newBar; int Start() { static datetime Time0; newBar = Time[shift] > Time0; Time0 = Time[shift]; if (!newBar) return;or equivalent.
for (int i = 0; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {This fails when closing orders. index 2 becomes index 1, etc and you'll no close everything. Always check orderSelect.
for(int index = OrdersTotal() - 1; index >= 0; index--) if ( OrderSelect(index, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == MagicNumber // my magic number && OrderSymbol() == Symbol() ) { // and period and symbol //...
if (UseTakeProfit) 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) {always check for failure and print out the values so you know why. Also Slippage=3, TakeProfit=200. What you want is pips, and on a 5 digit broker a point is not a pip. so slippage becomes 3/10 pips. Keep your value in pips and have the ea adjust
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init() { if (Digits == 5 || Digits == 3) { // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } //... if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * pips2dbl; else TakeProfitLevel = 0.0; Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage*pips2points , StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue); if (ticket < 0) { Alert( "OrderSend(type=Buy","), lots=", size, ", price=", DoubleToStr( Ask, Digits ), "), SL= ...) failed: ",GetLastError());As for why, print out the values of each variable
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { if(!IsTrade) { // orderSend...
WHRoeder:
Once you reach maximum bars in chart, Bars will not change. Use: or equivalent. This fails when closing orders. index 2 becomes index 1, etc and you'll no close everything. Always check orderSelect. always check for failure and print out the values so you know why. Also Slippage=3, TakeProfit=200. What you want is pips, and on a 5 digit broker a point is not a pip. so slippage becomes 3/10 pips. Keep your value in pips and have the ea adjust As for why, print out the values of each variable
thank you for your help
i am still a rookie to programing.
so i change this line here to
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
//if (EachTickMode) Current = 0; else Current = 1;
if (EachTickMode && Bars != BarCount) TickCheck = False;
return(0);
then i can use this
or leave it like this
bool IsTrade = False;
for (int i = 0; i < Total; i ++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol())
{
In here and remove the next 3 lines
IsTrade = True;
if(OrderType() == OP_BUY)
{
//Close
or is it part of the signal begin exit Buy
You gave me a mouth full to look at and i thank you for that. i am learning.
you might wonder how i wrote this Ea with out knowledge of programing - i had a template and do some changes to it
but know i am stuck and ask help
can you help me with the above and while i figure out the next as per your explanation. that what you gave me is good programing. i just need to
see how it all fits in
Once you reach maximum bars in chart, Bars will not change. Use: or equivalent. This fails when closing orders. index 2 becomes index 1, etc and you'll no close everything. Always check orderSelect. always check for failure and print out the values so you know why. Also Slippage=3, TakeProfit=200. What you want is pips, and on a 5 digit broker a point is not a pip. so slippage becomes 3/10 pips. Keep your value in pips and have the ea adjust As for why, print out the values of each variable
thank you for your help
i am still a rookie to programing.
so i change this line here to
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
//if (EachTickMode) Current = 0; else Current = 1;
if (EachTickMode && Bars != BarCount) TickCheck = False;
return(0);
then i can use this
bool newBar; int Start() { static datetime Time0; newBar = Time[shift] > Time0; Time0 = Time[shift]; if (!newBar) return;
or leave it like this
for (int i = 0; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {this section here
for(int index = OrdersTotal() - 1; index >= 0; index--) if ( OrderSelect(index, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == MagicNumber // my magic number && OrderSymbol() == Symbol() ) { // and period and symbol //...program it here
bool IsTrade = False;
for (int i = 0; i < Total; i ++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol())
{
In here and remove the next 3 lines
IsTrade = True;
if(OrderType() == OP_BUY)
{
//Close
or is it part of the signal begin exit Buy
You gave me a mouth full to look at and i thank you for that. i am learning.
you might wonder how i wrote this Ea with out knowledge of programing - i had a template and do some changes to it
but know i am stuck and ask help
can you help me with the above and while i figure out the next as per your explanation. that what you gave me is good programing. i just need to
see how it all fits in
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register