stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Need advise on this code
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3740
Page 4 of 5
Author:  fxcba [ Sat Sep 13, 2014 10:25 am ]
Post subject:  Need advise on this code

Thank you for your help Steve, have a nice weekend 8-)
Ric
Author:  fxcba [ Thu Sep 18, 2014 6:47 pm ]
Post subject:  Need advise on this code

Hello
This is an EA I recoded mixing 2 EAs, both were downloaded from mql5 data base, given my little knowledge I'm pretty sure code is a mess, but it looks functional, I'm facing two problems and I wonder if any of you can take a look.
First issue is not placing buy stop order at right level , it seems sell stop order it's ok, b ut please check it out.
Second after placing the orders it fails setting SL and TP.

Logic of this EA is to put 2 pending orders at previous H and L minus/plus buffer pips at predeterminated time.
Original EAs work fine individually, so I'm pretty sure that with a little tweak its going to work.
Ric
Author:  SteveHopwood [ Thu Sep 18, 2014 9:08 pm ]
Post subject:  Need advise on this code

fxcba » Thu Sep 18, 2014 6:47 pm wrote:Hello
This is an EA I recoded mixing 2 EAs, both were downloaded from mql5 data base, given my little knowledge I'm pretty sure code is a mess, but it looks functional, I'm facing two problems and I wonder if any of you can take a look.
First issue is not placing buy stop order at right level , it seems sell stop order it's ok, b ut please check it out.
Second after placing the orders it fails setting SL and TP.

Logic of this EA is to put 2 pending orders at previous H and L minus/plus buffer pips at predeterminated time.
Original EAs work fine individually, so I'm pretty sure that with a little tweak its going to work.
Ric
Lok at lines 111-113.

Code: Select all

// Calculate stop loss
double slb=NormalizeDouble(Ask-SL*Point,Digits);
double sls=NormalizeDouble(Bid+SL*Point,Digits);
They are basing the stops on the market price, yet the pendings are based on some sort of hilo of previous bars - can't work out which ones. So, sl modification will often fail - see line 185 and 188.

The snippet of code at 143-151 omits a check for the chart symbol, so any trade open on the chart with the same magic number will stop the upcoming pending trade. You will find the correct way of iterating through the list of trades correctly in any one of the hundreds of ea's I have posted here and elsewhere. Look in CountOpenTrades() in my shells, or FB, or...............................

If an order send/modify fails, there is no error checking to report back why. Granted, the report back is often useless rubbish, but that is CrapQLx for you. At least with error checking, you know there was a blunder in the code.

double CheckForModify() isn't even called; at least CrapQL4 informed the coder of such redundant functions.

Basically, this code is rubbish and you would be better off starting from scratch and writing your own. If nothing else, you would learn how to code.

:xm:
Author:  fxcba [ Thu Sep 18, 2014 10:48 pm ]
Post subject:  Need advise on this code

Hey Steve, thank you buddy, explained is better :clap:
Basically, this code is rubbish and you would be better off starting from scratch and writing your own. If nothing else, you would learn how to code.
I know, and I'm doing another ea this way alreay (I've downloaded your shell ea)but progress is slow :arrrg: and messing with other's code is helping to learn.
Cheers
Author:  SteveHopwood [ Thu Sep 18, 2014 11:01 pm ]
Post subject:  Need advise on this code

fxcba » Thu Sep 18, 2014 10:48 pm wrote:Hey Steve, thank you buddy, explained is better :clap:

I know, and I'm doing another ea this way already (I've downloaded your shell ea)but progress is slow :arrrg: and messing with other's code is helping to learn.
Cheers
Up an at 'em, Tiger. :clap:

Where you are right now, a lot of the so-called 'Help' accessed via the F1 key probably reads like garbage. For sure, it is not written by anybody who really understands this stuff and so can write help in such a way that inexperienced coders can understand it. They should team up with Microsoft and work at producing so-called 'help' that does not even resemble a written language.

The better you get at this stuff, the easier it becomes to understand the claptrap. There is no shortcut for us normal people (I do not count anybody with a computer science degree as 'normal' - sorry guys but you are just plain weird); we just have to do the hard gazillions of miles until we start to understand it all.

Keep going. You will not be sorry. Guess how I know?

:xm:
Author:  Cheeter [ Fri Oct 03, 2014 5:58 pm ]
Post subject:  Need advise on this code

Hi I am getting an error on the first line. If some one could help would be very appreciated.
Thank you Cheeter

Code: Select all

void delete(int type){
   if(OrdersTotal()>0){
      for(i=OrdersTotal()-1;i>=0;i--){
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(type!=6 && type!=7 && type!=8)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==type)OrderDelete(OrderTicket());
         if(type==6)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket());
         if(type==7)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT)OrderDelete(OrderTicket());
         if(type==8)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket());
      }
   }
}
Author:  milanese [ Fri Oct 03, 2014 6:19 pm ]
Post subject:  Need advise on this code

Cheeter » Fri Oct 03, 2014 5:58 pm wrote:Hi I am getting an error on the first line. If some one could help would be very appreciated.
Thank you Cheeter

Code: Select all

void delete(int type){
   if(OrdersTotal()>0){
      for(i=OrdersTotal()-1;i>=0;i--){
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(type!=6 && type!=7 && type!=8)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==type)OrderDelete(OrderTicket());
         if(type==6)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket());
         if(type==7)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT)OrderDelete(OrderTicket());
         if(type==8)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket());
      }
   }
}
try this:

Code: Select all

void delete_function(int type){
        
           if(OrdersTotal()>0){
              for(int i=OrdersTotal()-1;i>=0;i--){
                 OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
                 if(type!=6 && type!=7 && type!=8)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==type)OrderDelete(OrderTicket());
                 if(type==6)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket());
                 if(type==7)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT)OrderDelete(OrderTicket());
                 if(type==8)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket());
              }
           }
        }
as delete can not be used as name for your function..

Cheers :)

Tommaso
Author:  Cheeter [ Fri Oct 03, 2014 6:30 pm ]
Post subject:  Need advise on this code

Thank you Tommaso that did the trick. cheeter
Author:  fxcba [ Wed Oct 15, 2014 6:06 pm ]
Post subject:  Need advise on this code

fxcba » Thu Sep 18, 2014 3:47 pm wrote:Hello
This is an EA I recoded mixing 2 EAs, both were downloaded from mql5 data base, given my little knowledge I'm pretty sure code is a mess, but it looks functional, I'm facing two problems and I wonder if any of you can take a look.
First issue is not placing buy stop order at right level , it seems sell stop order it's ok, b ut please check it out.
Second after placing the orders it fails setting SL and TP.

Logic of this EA is to put 2 pending orders at previous H and L minus/plus buffer pips at predeterminated time.
Original EAs work fine individually, so I'm pretty sure that with a little tweak its going to work.
Ric
Hello, code-masters
I've managed to make this bot run, well, is crawling yet, but I'm closer. I want the ea
1º- send two pending orders (done)
2º- send orders at specified time (done)
3º- orders with SL and TP (done)
4º- the pending orders have to be at certain distance from high and low of previuos hour candle (fail)
I'm having trouble with this.
EA reads the distance and send orders but not adding at previous hour high nor subtracting the previous hourly low.
Any hint would be appreciated.
Dear Steve I'm still strugling with your shell ea, I didn't get it yet :(, but I have a couple of ideas to implement on it when time comes or my brain awakes.
Cheers Ric
Author:  Lowphat [ Wed Oct 15, 2014 9:23 pm ]
Post subject:  Need advise on this code

MyPoint=Point*10
(Low[1]-spread*MyPoint)-(pointsPastLow*MyPoint)
All times are UTC Page 4 of 5