Spready

Post Reply
User avatar
SteveHopwood
Owner
Posts: 9701
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Spready

Post by SteveHopwood »

SERIOUS WARNING
  • Most Forex traders lose all their money.
  • Using the robot posted here in trading Forex does not guarantee success.
  • Trading this robot could lead to serious financial loss.
  • Trading this robot without understanding its underlying trading strategies guarantees traders will lose their money.
  • This is not a set-and-forget ea; there is no such thing and anyone who tries to claim there is, is either stupid or lying. This ea requires frequent manual intervention.
  • At best, a trading robot is only 90% as good as the manual strategy it trades. At best. At worst, it can be much less effective. If the strategy is rubbish, so is the robot.
  • To trade this robot, you have to understand:
    • How to use EA's.
    • Hedging
    • Basket trading
MAKE SURE YOU READ THIS POST http://www.stevehopwoodforex.com/phpBB3 ... 41#p111241 There was a Forex bloodbath on Jan 15th 2015 that you need to know about.

I noticed this on an Afterprime demo:
Zero spread.PNG
Lots of zero spreads mean that simultaneous buy and sell orders can be placed at the same price. There were never more than 2 points in between the orders even when the timing did not quite work out.

Open a hedged pair of buy and sell orders. Place a grid of 10 buy and sell stops then wait for the market to do its thing. Treat each pair as an individual basket and close the orders at a set profit target. One side will eventually overwhelm the other even when a ranging market fills a number of stop orders on both sides.

I dropped the initial market orders after a while so here is what Spready does:
  • Wait for a zero spread event then:
    • Send a grid of x (default 10) stop orders x pips from the market(default 20).
    • Monitor the position awaiting the opportunity to close at the basket cash TP target. Set this target to lot size multiplied by 10, so the default lot size of 0.1 gives a $100 profit target.
There are no individual trade TP/SL although the inputs are there for anyone wanting to experiment with them.

This is an experiment and I cannot believe it has not been tried before; we shall have to try it and see. The demo is up 35% since starting and so looks promising.

I have included a couple of scripts to aid manual closing. The Nuclear Option script sets a flag during its operation, that Spready spots and waits for the flag to disappear before carrying out further operations.

Try Spready out and see if she works for you.




:xm: :rocket:

Matters of general interest
Go here to download and run the script that will fill your platform's missing chart history: http://www.stevehopwoodforex.com/phpBB3 ... f=15&t=254
Read this post:
http://www.stevehopwoodforex.com/phpBB3 ... p?f=6&t=78 Newbie traders, read this for inspiration and warning. Those of you who have suffered losses, read it for inspiration.

Masterly summary of hedging: http://www.forexfactory.com/showthread. ... ost4977179

EA coding
I receive may requests to code EA's. Traders, if I code your EA for free, then I will share it here. If you want me to code your EA without sharing, then my fee is $100 payable into my paypal account. I explain why at http://www.stevehopwoodforex.com/phpBB3 ... ?f=15&t=79, at the bottom of the post.

Useful utilities/EA's/scripts -

-
You do not have the required permissions to view the files attached to this post.
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
biobier
Trader
Posts: 68
Joined: Mon Mar 18, 2019 7:24 am

Re: Spready

Post by biobier »

Nice toy Steve.
I assume in a live account the slippage will make this not profitable but we shall see.
I suggest to use a OrderCloseby function to offset the initial Buy and Sell before the CloseAllTrades. This will save comission once.

Code: Select all

//CHeck if broker allows CloseBy
if((int)MarketInfo(Symbol(),MODE_CLOSEBY_ALLOWED)==1)
	multiple_closeby(symbol==AllSymbols?NULL:Symbol(),MagicNumber,true);
CloseAllTrades(AllTrades);

bool multiple_closeby(const string symbol=NULL, const int magic=NULL,bool sameLotOnly=false)
{
   for(int i=OrdersTotal()-1; i>0; --i){
      //first loop by all orders
      if(OrderSelect(i, SELECT_BY_POS)
         && OrderType() < 2
         && (symbol == NULL || OrderSymbol() == symbol)
         && (magic == NULL  || OrderMagicNumber() == magic)
      ){
         int    first_ticket = OrderTicket();
         string first_symbol = OrderSymbol();
         int    first_type   = OrderType();
         double first_lot    = OrderLots();
         double first_profit = OrderProfit();
         bool lookForFullBalance=true;
         for(int j=OrdersTotal()-1; j>=0; --j){
            //second loop to find suitable trade that has enough profit to blance this one out at least by 100%
            if(OrderSelect(j, SELECT_BY_POS)
               && OrderType() < 2
               && (magic == NULL || OrderMagicNumber() == magic)
               && OrderSymbol() == first_symbol
               && OrderType()   != first_type
               && OrderTicket() != first_ticket
               && (!sameLotOnly || first_lot==OrderLots())
            ){
               while(IsTradeContextBusy()) Sleep(10);
               if(!lookForFullBalance || (lookForFullBalance && first_profit*-1 <= OrderProfit())){
                  if(OrderCloseBy(first_ticket, OrderTicket()))
                     return multiple_closeby(symbol, magic,sameLotOnly);//new call as the orders situation changed
                  else
                     return false;
               }else if(lookForFullBalance && j<0){ //now look again for no full balance
                 lookForFullBalance=false;
                 j=OrdersTotal()-1;
              }
            }
         }//for
      }//if
   }//for
   return true;

Must-reads for FOREX NOOBS as me:
Help for Newbies.
Information For Beginners
User avatar
SteveHopwood
Owner
Posts: 9701
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: Spready

Post by SteveHopwood »

biobier wrote: Fri Sep 22, 2023 10:25 am Nice toy Steve.
I assume in a live account the slippage will make this not profitable but we shall see.
I suggest to use a OrderCloseby function to offset the initial Buy and Sell before the CloseAllTrades. This will save comission once.
Thanks biobier. I tried adding the code but the compilation fails with errors at the two highlighted bits:
multiple_closeby(symbol==AllSymbols?NULL:Symbol(),MagicNumber,true);

Am I missing a couple of declarations?

:xm: :rocket:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Post Reply

Return to “Automated trading systems”