Rinse 'n Repeat

Post Reply
pipseee

Rinse 'n Repeat

Post by pipseee »

heart1010 » Mon Apr 25, 2016 7:18 am wrote:DAX today (0.1 lots/5 point distance) looking also good until know :hi: (after it was about ~80€ in loss it came back and is now 21€ in profit)
You do not have the required permissions to view the files attached to this post.
spymez
Trader
Posts: 18
Joined: Wed Feb 29, 2012 1:33 pm

Rinse 'n Repeat

Post by spymez »

ludowillems » Mon Apr 25, 2016 10:35 pm wrote:OOTB and up 5% in a couple of hours.! :clap:
For your info:

When downloading the simulator (http://www.stevehopwoodforex.com/phpBB3 ... p?id=60161),
W10 and his Defender interprets this .rar file as a virus. I PM'd Tomasso about this who explained that sometimes a .rar is identified as a virus. So I temporarely disabled Defender and the download was OK.
Hi ludowillems

Which Empty4 criminal are you using for cfds? (Dax).

My broker has min lot size of 1.0 for indices. (ICMarkets).

Or are we all using Global Prime here...

***Thanks for Steve and co their contribution. :clap:

Cheers

Spy
heart1010
Trader
Posts: 56
Joined: Wed Mar 30, 2016 8:33 pm

Rinse 'n Repeat

Post by heart1010 »

This is GKFX.

(because GP doesn't offer cfd's at the moment... but in "near future" they will jeremy said)
User avatar
Gertje
Trader
Posts: 1936
Joined: Mon Dec 12, 2011 1:17 pm
Location: Middle of the Netherlands

Rinse 'n Repeat

Post by Gertje »

heart1010 » Mon Apr 25, 2016 2:00 pm wrote:This is GKFX.

(because GP doesn't offer cfd's at the moment... but in "near future" they will jeremy said)
Who needs CFD's with performance like this? :yahoo:
User avatar
PeterUK
Trader
Posts: 79
Joined: Fri Jun 27, 2014 2:18 pm
Location: London, UK

Rinse 'n Repeat

Post by PeterUK »

CFD's are generally good for slow uptrends, and sudden downtrends... FTSE, S&P, Coffee and etc...

If you're looking do demo trade Index's and etc you can also try AxiTrader demo...

Regards,

Peter
Knowledge owned is Pointless. Knowledge Shared is Priceless!
thomasmore
Trader
Posts: 275
Joined: Tue Nov 15, 2011 10:35 pm
Location: Knokke, Belgium

Rinse 'n Repeat

Post by thomasmore »

spymez » 25 Apr 2016, 15:58 wrote:
Hi ludowillems

Which Empty4 criminal are you using for cfds? (Dax).

My broker has min lot size of 1.0 for indices. (ICMarkets).

Or are we all using Global Prime here...

***Thanks for Steve and co their contribution. :clap:

Cheers

Spy
Sorry, Spy, that DAX chart is not from me...
Cheers
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Rinse 'n Repeat

Post by SteveHopwood »

V 1a is in post 1.

PartialEmergencyStopLossPercentOfBalance is a brilliant idea by Bruster. :clap: :clap: :clap: :clap: Instead of closing the entire position when the stop loss is hit, close just the worst trade in the hope that the position recovers. If not, RnR will carry on closing the worst trades at the stop loss until profit taking resumes.

We can probably remove the full position closure; leave it alone for now.

:xm:
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. pianodoodler@hotmail.com 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.
szfxtrader
Trader
Posts: 377
Joined: Sun Feb 10, 2013 9:36 am

Rinse 'n Repeat

Post by szfxtrader »

SteveHopwood » Mon Apr 25, 2016 3:39 pm wrote:V 1a is in post 1.

PartialEmergencyStopLossPercentOfBalance is a brilliant idea by Bruster. :clap: :clap: :clap: :clap: Instead of closing the entire position when the stop loss is hit, close just the worst trade in the hope that the position recovers. If not, RnR will carry on closing the worst trades at the stop loss until profit taking resumes.

We can probably remove the full position closure; leave it alone for now.

:xm:
Thanks a lot!
User avatar
cyberevil
Trader
Posts: 95
Joined: Mon Oct 26, 2015 5:55 pm
Location: Vancouver, BC

Rinse 'n Repeat

Post by cyberevil »

roman01 » April 25th, 2016, 8:15 am wrote:Hi guys, I'm new here, I have a stupid question, what is OOTB ? Some EA like account manager ? If yes, where I can find last version.
Thank you so much.
OOTB is Out Of The Box . aka use it as it compiles and don't make any changes to any variables. :youknow:
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Rinse 'n Repeat

Post by SteveHopwood »

V 1b is in post 1. Bruster spotted a flaw in part of the logic that was intended to ensure that only profitable trades are considered for the complex offsetting thingy.

I am seeing some invalid ticket errors in Craptesting, so I have tried to fix those but they are still happening.

There will be at least one more release today - Bruster has had another idea. :party:

Here is the updated code should you wish to make the change yourselves - just copy it over the top of the existing function.

:xm:

Code: Select all

void ShouldTradesBeClosed()
{
   //Examine baskets of trades for possible closure
   
   if (OpenTrades == 0)
      return;//Nothing to do

   //int tries = 0;
   bool CloseTrades = false;
   
   double pips = 0;//The pips upl of the highest buy or lowest sell
   double loss = 0;//Convers pips to a positive value for comparison with (DistanceBetweenTrades / factor)
   double profit = 0;//Cash upl of the side being calculated to see if they can combine to close a loser on the other side
   int TradesToClose = 0;
   bool result = false;
   int cc = 0;
   double HighestTradeCash = 0;
   double LowestTradeCash = 0;
   
   
   //Look for basket closure.
   //Hedged basket
   if (HedgedBasketPips > 0)
      if (PipsUpl >= HedgedBasket)
      {
         CloseAllTrades(AllTrades);
         if (ForceTradeClosure)
            CloseAllTrades(AllTrades);
         return;
      }//if (PipsUpl >= HedgedBasket)
      
   //Un-hedged
   if (ClearBasketPips > 0)
      if (PipsUpl >= ClearBasket)
      {
         CloseAllTrades(AllTrades);
         if (ForceTradeClosure)
            CloseAllTrades(AllTrades);
         return;
      }//if (PipsUpl >= HedgedBasket)
      
   //Emergency stop loss
   if (!CloseEnough(EmergencyStopLossPercentageOfBalance, 0))
      if (CashUpl < 0)
         if ((CashUpl) <= EmergencyStopLoss)
         {
            CloseAllTrades(AllTrades);
            if (ForceTradeClosure)
               CloseAllTrades(AllTrades);
            return;
         }//if ((CashUpl * -1) <= EmergencyStopLoss)
      
   //Close the worst trade if stop loss is hit
   if (!CloseEnough(PartialEmergencyStopLossPercentOfBalance, 0))
   {        
      double PartialEmergencyStopLoss = AccountBalance() * (PartialEmergencyStopLossPercentOfBalance / 100) *-1;
      if ((CashUpl) <= PartialEmergencyStopLoss)
      {
         // find the worst losing trade which is either going to be the highest buy or the lowest sell:
       
         if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
               double HighestBuyCash = OrderSwap() + OrderCommission() + OrderProfit();  
         
         if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
               double LowestSellCash = OrderSwap() + OrderCommission() + OrderProfit(); 
       
         if ((HighestBuyCash < LowestSellCash)) // the buy is the worst trade
         {
            if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
            {
               result = CloseOrder(HighestBuyTicketNo);
               if(result)Print("Closed highest buy at partial emergency stop level");
               if (!result)
               {
                  CountOpenTrades(); // just in case it's a ticket number issue.
                  return;
               }//if (!result)        
            }//if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )         
         }//if ((HighestBuyCash < LowestSellCash))
         else
         {
            if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
            {   
               result = CloseOrder(LowestSellTicketNo);
               if(result)Print("Closed lowest sell at partial emergency stop level");
               if (!result)
               {
                  CountOpenTrades(); // just in case it's a ticket number issue.
                  return;
               }//if (!result)
            }//if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
         }//else      
   
      }//if ((CashUpl) <= PartialEmergencyStopLoss)
   }//if (!CloseEnough(PartialEmergencyStopLossPercentOfBalance, 0))
   

   CloseTrades = false;

   //Look for a simple offset opportunity of a losing buy at the
   //top of the pile by the winner at the bottom.
   if (MarketBuysCount > 3)//Impossible with < 4
   {
      //Do we have a losing buy?
      if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
      {
         //Calculate the pips upl of the highest, and so latest, buy
         pips = CalculateTradeProfitInPips(OP_BUY);
         if (pips < 0)//Only continue if it is losing
         {
            loss = (pips * -1);//Turn the loss into a positive number for the comparison
            if (loss >= DistanceBetweenTrades)//Only continue if losing by at least 1 grid level
            {
               HighestTradeCash = OrderSwap() + OrderCommission() + OrderProfit();
               if (OrderSelect(LowestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                  LowestTradeCash = OrderSwap() + OrderCommission() + OrderProfit();
               
               //Make sure we are closing at an overall cash profit
               if ((HighestTradeCash + LowestTradeCash) > 0)
               {
                  //The higest buy trade is losing by at least one grid level, so close it and the lowest buy
                  if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                  {
                     result = CloseOrder(HighestBuyTicketNo);
                     if (!result)
                     {
                        return;
                     }//if (!result)
                  }//if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                     
                  if (OrderSelect(LowestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                  {
                     result = false;
                     while (!result)
                     {
                        result = CloseOrder(LowestBuyTicketNo);               
                     }//while (!result)
                  }//if (OrderSelect(LowestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                     
                  CountOpenTrades();
                  return;
                  
               }//if ((HighestTradeCash + LowestTradeCash) > 0)                  
            }//if (loss >= DistanceBetweenTrades)
            
         }//if (pips < 0)
      }//if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
          
   }//if (MarketBuysCount > 3)
     
   //Look for a simple offset opportunity of a losing buy at the
   //top of the pile by the winner at the bottom.
   if (MarketSellsCount > 3)//Impossible with < 3
   {

      //Do we have a losing buy?
      if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
      {
         //Calculate the pips upl of the lowest, and so latest, sell
         pips = CalculateTradeProfitInPips(OP_SELL);

         if (pips < 0)//Only continue if it is losing
         {
            loss = (pips * -1);//Turn the loss into a positive number for the comparison

            if (loss >= DistanceBetweenTrades)//Only continue if losing by at least 1 grid level
            {
               LowestTradeCash = OrderSwap() + OrderCommission() + OrderProfit();
               if (OrderSelect(HighestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                  HighestTradeCash = OrderSwap() + OrderCommission() + OrderProfit();

               if ((HighestTradeCash + LowestTradeCash) > 0)
               {
                  if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                  {
                     result = CloseOrder(LowestSellTicketNo);
                     if (!result)
                     {
                        return;
                     }//if (!result)
                  }//if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                  
                  if (OrderSelect(HighestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                  {   
                     result = false;
                     while (!result)
                     {
                        result = CloseOrder(HighestSellTicketNo);               
                     }//while (!result)
                  }//if (OrderSelect(HighestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                     
                  CountOpenTrades();
                  return;
                  
               }//if ((HighestTradeCash + LowestTradeCash) > 0)               
            }//if (loss >= DistanceBetweenTrades)
            
         }//if (pips < 0)
      }//if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
          
   }//if (MarketSellsCount  > 3)
       
     
   ////////////////////////////////////////////////////////////////////////
   //Got this far, so see if the combined winners on one side can combine
   //to close a loser on the other side.
   
   
   if (Hedged)
   {
      double CashLoss = 0;
      double CashProfit = 0;
      int NoOfTrades = 0;
      bool ClosePossible = false;
      int ClosureTickets[];
      ArrayInitialize(ClosureTickets, -1);
      
      //Can we offset some buy trades against the lowest losing sell trade
      if (BuyCashUpl > 0)//The buy side of the hedge must be profitable overall
         if (MarketBuysCount >= 3)//Must be sufficient trades open to start offsetting
            if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES))//Select the lowest sell
            {
               CashLoss = (OrderSwap() + OrderCommission() + OrderProfit());//Calculate its cash position
               if (CashLoss < 0)//Is it losing?
               {
                  CashLoss*= -1;//Convert to a positive for comparison with the profit on the other side
                  //Calculate the profit on the other side of the hedge
                  for (cc = MarketBuysCount; cc > 0; cc--)
                  {
                     if (OrderSelect(FifoBuyTicket[cc - 1][TradeTicket], SELECT_BY_TICKET, MODE_TRADES) )
                     {
                        CashProfit+= (OrderSwap() + OrderCommission() + OrderProfit());
                        if (CashProfit > 0)
                           if (!CloseEnough(CashProfit, 0) )
                           {
                              NoOfTrades++;
                              ArrayResize(ClosureTickets, NoOfTrades);
                              ClosureTickets[NoOfTrades - 1] = OrderTicket();
                           }//if (!CloseEnough(CashProfit, 0) )
                     }//if (OrderSelect(FifoBuyTicket[cc - 1][ticket], SELECT_BY_TICKET, MODE_TRADES) )
                     
                     //Is the profit big enough to close the trade on the other side of the hedge?
                     if (CashProfit >= CashLoss)
                     {
                        //Yippee
                        ClosePossible = true;
                        break;
                     }//if (CashProfit >= CashLoss)
                  }//for (int cc = MarketBuysCount; cc >= 0; cc--)
                  
                  //Are there closures to make?
                  if (ClosePossible)
                  {
                     ForceTradeClosure = true;
                     while (ForceTradeClosure)
                     {
                        ForceTradeClosure = false;
                        if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                        {
                           result = CloseOrder(LowestSellTicketNo);
                           if (!result)
                              ForceTradeClosure = true;
                        }//if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                        
                        for (cc = ArraySize(ClosureTickets) - 1; cc >= 0; cc--)
                        {
                           if (OrderSelect(ClosureTickets[cc], SELECT_BY_TICKET, MODE_TRADES))
                           {
                              result = CloseOrder(ClosureTickets[cc]);
                              if (!result)
                              {
                                 ForceTradeClosure = true;
                                 cc++;
                              }//if (!result)
                           }//if (OrderSelect(ClosureTickets[cc], SELECT_BY_TICKET, MODE_TRADES))                          
                        }//for (cc = ArraySize(ClosureTickets); cc >= 0; cc--)
                     }//while (ForceTradeClosure)
                     CountOpenTrades();
                     return;
                  }//if (ClosePossible)
               }//if (CashLoss < 0)
            }//if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES))
            
      CashLoss = 0;
      CashProfit = 0;
      NoOfTrades = 0;
      ClosePossible = false;
      ArrayResize(ClosureTickets, 0);
      ArrayInitialize(ClosureTickets, -1);

      //Can we offset some sell trades against the highest losing buy trade
      if (SellCashUpl > 0)//The sell side of the hedge must be profitable overall
         if (MarketSellsCount >= 3)//Must be sufficient trades open to start offsetting
            if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES))//Select the highest buy
            {
               CashLoss = (OrderSwap() + OrderCommission() + OrderProfit());//Calculate its cash position
               if (CashLoss < 0)//Is it losing?
               {
                  CashLoss*= -1;//Convert to a positive for comparison with the profit on the other side
                  //Calculate the profit on the other side of the hedge
                  for (cc = 0; cc < MarketSellsCount; cc++)
                  {
                     if (OrderSelect(FifoSellTicket[cc][TradeTicket], SELECT_BY_TICKET, MODE_TRADES) )
                     {
                        CashProfit+= (OrderSwap() + OrderCommission() + OrderProfit());
                        if (CashProfit > 0)
                           if (!CloseEnough(CashProfit, 0) )
                           {
                              NoOfTrades++;
                              ArrayResize(ClosureTickets, NoOfTrades);
                              ClosureTickets[NoOfTrades - 1] = OrderTicket();
                           }//if (!CloseEnough(CashProfit, 0) )
                     }//if (OrderSelect(FifoSellTicket[cc1][TradeTicket], SELECT_BY_TICKET, MODE_TRADES) )
                     
                     //Is the profit big enough to close the trade on the other side of the hedge?
                     if (CashProfit >= CashLoss)
                     {
                        //Yippee
                        ClosePossible = true;
                        break;
                     }//if (CashProfit >= CashLoss)
                  }//for (cc = 0; cc < MarketSellsCount - 1; cc++)
                  
                  //Are there closures to make?
                  if (ClosePossible)
                  {
                     ForceTradeClosure = true;
                     while (ForceTradeClosure)
                     {
                        ForceTradeClosure = false;
                        if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                        {
                           result = CloseOrder(HighestBuyTicketNo);
                           if (!result)
                              ForceTradeClosure = true;
                        }//if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                        
                        for (cc = ArraySize(ClosureTickets) - 1; cc >= 0; cc--)
                        {
                           if (OrderSelect(ClosureTickets[cc], SELECT_BY_TICKET, MODE_TRADES))
                           {
                              result = CloseOrder(ClosureTickets[cc]);
                              if (!result)
                              {
                                 ForceTradeClosure = true;
                                 cc++;
                              }//if (!result)
                           }//if (OrderSelect(ClosureTickets[cc], SELECT_BY_TICKET, MODE_TRADES))                          
                        }//for (cc = ArraySize(ClosureTickets); cc >= 0; cc--)
                     }//while (ForceTradeClosure)
                     CountOpenTrades();
                     return;
                  }//if (ClosePossible)
               }//if (CashLoss < 0)
            }//if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES))
   
   }//if (Hedged)

   
}//void ShouldTradesBeClosed()
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. pianodoodler@hotmail.com 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”