Advanced Automated Trading #2

In this piece I’ll show some examples that are some of the less obvious ways automated trading can chip in with correcting human errors.

Human can have a fixation of wanting to do this or that and override/ignore signs that would suggest otherwise.

With all the good intentions, the human has to learn to comply as well.

I, as a human being with all the possible flaws in the world failed to acknowledge a zillion signs:

  • the fake-out of Mr. Maroon (in Maroon, see “F”)
  • the failure at the Lower Guard Rail (chartreuse)
  • the wave count down to 1 – corresponding “# sell label”
  • the wave 4 warning (purple stripe below)
  • the BURN plot highlighting a starting move down
  • wasn’t acknowledging the navy slim line up as a wave 5 or B up
  • that the market made a thrust into the thrust box (image at bottom)
  • that the market spiked over the red line (image at bottom)
  • (not to mention the pause before the lower reversal zone at 1.1176)
  • and above all the Golfer on the RSI2

The computer did notice it, and it kept on cutting my longs.

(Buy adding a stop loss of other than 0, you are submitting the trade for a review by the croppers.)

This frustrated me, because my croppers should be programmed not to take a loss. These losses were miniscule, $4 and $9.

My first impression was that I would have to change this and implement a protection for cutting only after a pip of gain, so that I can have some chump change left after the commission.

…and I did change it… and then I realized that the program was right all along. You may not get the luxury of a full pip in your favor. So I had to revert it back.

Here is the golf cropper for a long, now the bid line (that was inserted on an implusive decision unnecessarily, commented back out)

////Exit Long (Golfer On Top)
    if( OrderType()==OP_BUY && OrderMagicNumber()!=48 && OrderMagicNumber()!=50 && OrderMagicNumber()!=51 && OrderMagicNumber()!=52 && OrderMagicNumber()!=53 && OrderMagicNumber()!=54 && OrderProfit()>0 &&
    //Bid>OrderOpenPrice+10*Point &&
    omegam[0]<0 && RSI2[0]<60 && RSI2[1]>75 && RSI2[2]<75  ) 
        {OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
            Print("Golfer Cropper Closed LONG @ "+MarketInfo(OrderSymbol(), MODE_BID)+" for ", OrderProfit());} 

The second thing to talk about having to always update the system – which usually would come down to adding filters as problems arise.

The Slope Trader was most definitely missing a filter. You do not try to short near a fresh bottom.

There was a short opened on the spike low, and this was not the fault of the automated trading system, this was the fault of the designer not thinking things through.

 if (
      (Period()==30 && (trianglehigh[1] || trianglehigh[2] ||  trianglehigh[3] || trianglehigh[4] || trianglehigh[5] || trianglehigh[6]) && RSI2[0]>95 && Close[0]<iMA(NULL,240,207,0,MODE_EMA, PRICE_LOW,0))
    ||  (Period()==30 && (trianglelow[1] || trianglelow[2] ||  trianglelow[3] || trianglelow[4] ||  trianglelow[5] || trianglelow[6]) && RSI2[0]<5 && Close[0]<iMA(NULL,240,207,0,MODE_EMA, PRICE_LOW,0))
  &&!(iRSI(Symbol(),240,2,PRICE_MEDIAN,1)<3)
&&!(iRSI(Symbol(),240,2,PRICE_MEDIAN,2)<3)
&&!(iRSI(Symbol(),240,2,PRICE_MEDIAN,3)<3)
&&!(positive[10]==50 || positive[9]==50 ||  positive[9]==50 || positive[8]==50 || positive[7]==50 || positive[6]==50 || positive[5]==50 || positive[4]==50 || positive[3]==50 || positive[2]==50 || positive[1]==50 || positive[0]==50)
 && omegam[0]<0 && omegam[2]<0
 && DayOfWeek()!=0
///here comes the too close to the bottom filter 
 && Bid> iLow(symbol,30,iLowest(symbol,30,MODE_LOW,200,1))+FSize*10*Point
  )

Correction was made, but I am still traveling with the surplus weight of the short.

This is an excuse for having longs of course, but is a head ache as well.

Gotta think forward: if there was a short already opened occupying the maximum lot size, this trade would not had been opened or merely with insignificant size.

So, as a further prevention measure, I must allow the new Porker routine to open trades even if there are no counter-directional trades open. This of course does change the identity from a hedger to a trader.

Edit 1: (now equal included)

if (overhedging_allowed &&  Close[0]<iMA(symbol,30,135,0,MODE_EMA, PRICE_LOW,0)&& overdrivecounter<1 && no53s==0) {  
//now 0 longs = 0 shorts is a legitimate opening condition   
if (nshorts<=nlongs && piginthesky  ) {

Shadings show a directional logic.

Edit 2: New orders now can be opened with the equity dependent Max Lots size

if (i < 0){
      if (nlongs>0) if (OrderSend(symbol, OP_SELL, NormalizeDouble((nlongs-nshorts)*1.25,2), open_price, 3, stop_loss_price, take_profit_price, magic_number4+" OVERHEDGE SELL 0/0", magic_number4,1) < 0)
        Print("Error: ", ErrorDescription(_LastError));
              if (nlongs==0) if (OrderSend(symbol, OP_SELL, NormalizeDouble(MaxLots-nshorts,2), open_price, 3, stop_loss_price, take_profit_price, magic_number4+" OVERHEDGE SELL 0/0", magic_number4,1) < 0)
        Print("Error: ", ErrorDescription(_LastError));
        }
// Max Lots calculation for 1:200+ leverage
  extern int SLoss = 25;
extern double Leverage = 1.5;
extern double AF=1.3;
extern double LT=333;

double MaxLots = NormalizeDouble(LT/3000000*account*AF*Leverage/SLoss*260/2,2);     
  double comparison = AccountEquity()/AccountBalance();

Edit 3 and 4 are the counter part long overhedge lines.

One dilemma is reinstating the Rope trade at 15% equity draw down.

Lately I had only 50% hedge at 80% equity/balance ratio and 100% hedge at 70% ratio (for equity hedging, but there are plenty of other hedge warranting conditions), because it all may end up being a juggling act having to deal with too many hedge positions.

I recently added additional 2 hedges further down the equity line in case the human does bad things again.

image: thrust into the thrust box, spike over the red line