Peaky on Steroids

The place for Peaky and Peaky-related stuff.
Post Reply
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.

Peaky on Steroids

Post by SteveHopwood »

V 1h is in post 1, with the fix for the closure bloop. From the updated user guide:
[*]Trade1TradeComment: this is to help you identify which time frame generated a trade. This will aid gathering information about results on the different time frames. PoS uses the trade comment during the function that checks to see if a trade needs to be closed. It uses the comment to identify which time frame generated the trade. YOU MUST NOT alter the trade comment once there are open trades. PoS will be exceptionally rude to you if you do.
DIYers, copy this over the top of the existing bool LookForTradeClosure(int ticket) functionn - note there is a new function:

Code: Select all

int ExtractIndexFromTradeComment(string symbol, string comment)
{

   //Return the the time frame index from the order comment passed by LookForTradeClosure()
   
   if (comment == Trade1TradeComment)
      return(0);
      
   if (comment == Trade2TradeComment)
      return(1);
      
   if (comment == Trade3TradeComment)
      return(2);
      
   if (comment == Trade4TradeComment)
      return(3);
      
   //User has buggered up the order comment, so drive him nuts with an alert.
   Alert(symbol, ". You have buggered up your trade comments so PoS cannot work properly. Read the damn user guide and stop being an asshole. Cretins fail when trading Forex.");
   return(5);//Impossible value

}//End int ExtractIndexFromTradeComment(string symbol, string comment)


bool LookForTradeClosure(int ticket)
{
   //Close the trade if the close conditions are met.
   //Called from within CountOpenTrades(). Returns true if a close is needed and succeeds, so that COT can increment cc,
   //else returns false
   
   if (!BetterOrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES) ) 
      return(true);
   if (BetterOrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES) )
      if (OrderCloseTime() > 0)
          return(true);
   
   bool CloseThisTrade = false;
   
   //We need to know which time frame this trade belongs to
   int cc = ExtractIndexFromTradeComment(OrderSymbol(), OrderComment() );
   
   ///////////////////////////////////////////////////////////////////////////////////////////////////////////
   if (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP)
   {
      //TP
      if (bid >= OrderTakeProfit() ) 
         if (!CloseEnough(OrderTakeProfit(), 0) ) 
            CloseThisTrade = true;
      //SL
      if (bid <= OrderStopLoss() )
       if (!CloseEnough(OrderStopLoss(), 0) ) 
         CloseThisTrade = true;

      
      //Close trade on opposite direction signal
      if (SixthsTradingStatus[cc] == tradableshort)
         CloseThisTrade = true;

     
      
   }//if (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP)
   
   
   ///////////////////////////////////////////////////////////////////////////////////////////////////////////
   if (OrderType() == OP_SELL || OrderType() == OP_SELLSTOP)
   {
      //TP
      if (bid <= OrderTakeProfit() )
         if (!CloseEnough(OrderTakeProfit(), 0) ) 
            CloseThisTrade = true;
      //SL
      if (bid >= OrderStopLoss() ) 
         if (!CloseEnough(OrderStopLoss(), 0) ) 
            CloseThisTrade = true;


      //Close trade on opposite direction signal
      if (SixthsTradingStatus[cc] == tradablelong)
         CloseThisTrade = true;

      
      
      
   }//if (OrderType() == OP_SELL || OrderType() == OP_SELLSTOP)
   
   ///////////////////////////////////////////////////////////////////////////////////////////////////////////
   if (CloseThisTrade)
   {
      bool result = false;
      
      if (OrderType() < 2)//Market orders
         result = CloseOrder(ticket);
      else
         result = OrderDelete(ticket, clrNONE);
            
      //Actions when trade close succeeds
      if (result)
      {
         TicketNo = -1;//TicketNo is the most recently trade opened, so this might need editing in a multi-trade EA
         OpenTrades--;//Rather than OpenTrades = 0 to cater for multi-trade EA's
         return(true);//Makes CountOpenTrades increment cc to avoid missing out ccounting a trade
      }//if (result)
   
      //Actions when trade close fails
      if (!result)
      {
         return(false);//Do not increment cc
      }//if (!result)
   }//if (CloseThisTrade)
   
   //Got this far, so no trade closure
   return(false);//Do not increment cc
   
}//End bool LookForTradeClosure()
Also, go to the top of the file and do a search for "BuySignal". Delete the lines of code that delete BuySignal, SellSignal, BuyCloseSignal and SellCloseSignal. Recompile and follow the error messages to the errors that this will generate and delete the lines of code that contain these variables.

: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.
acostafulano
Trader
Posts: 243
Joined: Tue Dec 06, 2011 3:40 pm

Peaky on Steroids

Post by acostafulano »

Hello Steve,
I'd like to ask a question that is not entirely clear from the user guide, I hope it's not out of line:

For the Fill the gap and Recovery inputs: are the "MaxTradesAllowed" and "TradestoconstituteRecovery" parameters relative to each individual Timeframe or to the "pair" as a whole?

i.e: if TradesToConstituteRecovery=3 and I have 2 M1 buys and 1 M5 buy for a specific pair, am I already in recovery mode? or only when I get to 3 M1 buys will I be in recovery mode specifically for those 3 M1 buy trades?

Same question would apply for the max trades, is it per timeframe or per pair?

Thanks beforehand for the clarification

Diego
User avatar
TraderJoeForex
Trader
Posts: 1157
Joined: Fri Mar 08, 2013 10:29 pm
Location: South London

Peaky on Steroids

Post by TraderJoeForex »

acostafulano » Mon Jul 03, 2017 4:45 pm wrote:Hello Steve,
I'd like to ask a question that is not entirely clear from the user guide, I hope it's not out of line:

For the Fill the gap and Recovery inputs: are the "MaxTradesAllowed" and "TradestoconstituteRecovery" parameters relative to each individual Timeframe or to the "pair" as a whole?

i.e: if TradesToConstituteRecovery=3 and I have 2 M1 buys and 1 M5 buy for a specific pair, am I already in recovery mode? or only when I get to 3 M1 buys will I be in recovery mode specifically for those 3 M1 buy trades?

Same question would apply for the max trades, is it per timeframe or per pair?

Thanks beforehand for the clarification

Diego
Max trades is the total across all chosen pairs and time frames, recovery trades is per position. So 3 would mean 3 recovery trades on every pair and every timeframe independently.

EDIT: I confused max pairs and max trades here:

Max pairs is the total across all chosen pairs and time frames
Max trades is per recovery so every pair and timeframe independantly
Trades to constitute recovery is every pair and timeframe independantly
acostafulano
Trader
Posts: 243
Joined: Tue Dec 06, 2011 3:40 pm

Peaky on Steroids

Post by acostafulano »

Thanks for the clarification
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.

Peaky on Steroids

Post by SteveHopwood »

V 1i is in post 1.

I awoke this morning with what passes for my brain telling me that the code to limit the number of pairs being traded had the unwanted side effect of stopping trading on other time frames once a pair had traded and the max pairs had been reached. This is fixed in 1i and PoS instantly took a bunch of new trades on different time frames.

DIYers, copy this function just above OnTimer():

Code: Select all

bool AreWeAlreadyTradingThisPair(string symbol)
{

   //Returns true if this pair is already being traded on any time frame, else returns false.
   
   if (TradingPairs == 0) //Calculated in void CountCurrentlyTradingPairs()
      return(false);
      
   //Iterate through PairsWithOpenTrades[] to lok for a pair matching symbol
   for (int cc = 0; cc < ArraySize(PairsWithOpenTrades); cc++)
   {
      if (PairsWithOpenTrades[cc] == symbol)
         return(true);//Found one
   }//for (int cc = 0; cc < ArraySize(PairsWithOpenTrades); cc++)
      
   
   
   //Got this far, so not trading this pair
   return(false);

}//End bool AreWeAlreadyTradingThisPair(string symbol)
Do a compile so the compiler can whinge about the TradingPairs variable. Do a search for "//Open pairs counter" and change the variable that follows to TradingPairs. It was something like PairsWithTrades, which was too much like the PairsWithOpenTrades[] array.

Then do a search for "//A check that we are not already at our pairs limit" and copy this over the top of the existing code block:

Code: Select all

   //A check that we are not already at our pairs limit and we are not already trading this pair on another time frame. Abort the trade if so.
   //We want trading on different time frames if we are already trading a pair, hence the AreWeAlreadyTradingThisPair(string symbol) function.
   if (SendLong || SendShort)
      if (OrdersTotal() > 0)
      {
         CountCurrentlyTradingPairs();
         if (TradingPairs >= MaxPairsAllowed && !AreWeAlreadyTradingThisPair(symbol))
            return;   
      }//if (OrdersTotal() > 0)
      
 
One more change to make, inspired by Acosta's query - I am about to post about that. Do a global search and replace, changing "MaxTradesAllowed" to "MaxTradesAllowedPerTimeFrame".

: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.
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.

Peaky on Steroids

Post by SteveHopwood »

acostafulano » Mon Jul 03, 2017 4:45 pm wrote:Hello Steve,
I'd like to ask a question that is not entirely clear from the user guide, I hope it's not out of line:

For the Fill the gap and Recovery inputs: are the "MaxTradesAllowed" and "TradestoconstituteRecovery" parameters relative to each individual Timeframe or to the "pair" as a whole?

i.e: if TradesToConstituteRecovery=3 and I have 2 M1 buys and 1 M5 buy for a specific pair, am I already in recovery mode? or only when I get to 3 M1 buys will I be in recovery mode specifically for those 3 M1 buy trades?

Same question would apply for the max trades, is it per timeframe or per pair?

Thanks beforehand for the clarification

Diego
I went to check the User Guide for clarity and saw immediately why you were confused. I also saw that I had not completed the Recovery section. From the updated guide:
  • Fill the gap inputs: This group of inputs are telling Pos to follow a market that has filled a stop or limit order before continuing in the wrong direction for the trade. PoS will leave stop orders at (MarketDistancePips / 2) pips behind the market price. The purpose is to cash in on the inevitable reversal.
    • FollowAdverseMarketWithStopOrders: tells PoS to place the stops as the market moves against our market trade.
    • MarketDistancePips: tells PoS how far the market must move before sending a stop order. The order will be a half way between the most recent order open price (market or stop makes no difference) and the current price.
    • MaxTradesAllowedPerTimeFrame: this is the maximum number of trades that per per time frame that PoS is allowed to send. The default is 6, so if you are trading all four time frames then your maximum no of trades per pair is 24. If MaxPairsAllowed is set to its default of 5, then that gives a potential of 120 trades on the platform.
  • Recovery mode: imagine this scenario: the market reaches the peak high and fills the limit sell order then retraces and fills the sell stop order; we are in a healthy profit position and can allow the market to proceed to our take profit. Now imagine instead that the market continues to rise: PoS obediently leaves sell stop orders behind him - let's say 5; the market finally gets its bloody act together, does what it is damn well supposed to do and reverses; we are in a basic Recovery situation and trading the position as a basket. This input tells us how many trades we need to have open to be in Recovery and so treating the position as a basket. We simply want out and as soon as possible.
    • TradesToConstituteRecovery: this is the number of trades you need open per pair per time frame, to invoke Recovery and to look for closure at your chosen profit target. For example: the default is 3; you have 3 EU H1 buy trades open. The position is in Recovery.
    • RecoveryCashProfitTarget: no need to suffer the pain of Recovery without some reward, so this input tells PoS how much cash profit to lock in before closing the basket of trades.
    • RecoveryCashPercentageTarget: this sets your Recovery target as x% of your account balance.
: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.
User avatar
TraderJoeForex
Trader
Posts: 1157
Joined: Fri Mar 08, 2013 10:29 pm
Location: South London

Peaky on Steroids

Post by TraderJoeForex »

SteveHopwood » Tue Jul 04, 2017 8:44 am wrote:V 1i is in post 1.

I awoke this morning with what passes for my brain telling me that the code to limit the number of pairs being traded had the unwanted side effect of stopping trading on other time frames once a pair had traded and the max pairs had been reached. This is fixed in 1i and PoS instantly took a bunch of new trades on different time frames.

DIYers, copy this function just above OnTimer():

Code: Select all

bool AreWeAlreadyTradingThisPair(string symbol)
{

   //Returns true if this pair is already being traded on any time frame, else returns false.
   
   if (TradingPairs == 0) //Calculated in void CountCurrentlyTradingPairs()
      return(false);
      
   //Iterate through PairsWithOpenTrades[] to lok for a pair matching symbol
   for (int cc = 0; cc < ArraySize(PairsWithOpenTrades); cc++)
   {
      if (PairsWithOpenTrades[cc] == symbol)
         return(true);//Found one
   }//for (int cc = 0; cc < ArraySize(PairsWithOpenTrades); cc++)
      
   
   
   //Got this far, so not trading this pair
   return(false);

}//End bool AreWeAlreadyTradingThisPair(string symbol)
Do a compile so the compiler can whinge about the TradingPairs variable. Do a search for "//Open pairs counter" and change the variable that follows to TradingPairs. It was something like PairsWithTrades, which was too much like the PairsWithOpenTrades[] array.

Then do a search for "//A check that we are not already at our pairs limit" and copy this over the top of the existing code block:

Code: Select all

   //A check that we are not already at our pairs limit and we are not already trading this pair on another time frame. Abort the trade if so.
   //We want trading on different time frames if we are already trading a pair, hence the AreWeAlreadyTradingThisPair(string symbol) function.
   if (SendLong || SendShort)
      if (OrdersTotal() > 0)
      {
         CountCurrentlyTradingPairs();
         if (TradingPairs >= MaxPairsAllowed && !AreWeAlreadyTradingThisPair(symbol))
            return;   
      }//if (OrdersTotal() > 0)
      
 
One more change to make, inspired by Acosta's query - I am about to post about that. Do a global search and replace, changing "MaxTradesAllowed" to "MaxTradesAllowedPerTimeFrame".

:xm:
Ahh yes that is helpful, thanks!
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.

Peaky on Steroids

Post by SteveHopwood »

acostafulano » Mon Jul 03, 2017 4:45 pm wrote:Hello Steve,
I'd like to ask a question that is not entirely clear from the user guide, I hope it's not out of line:

For the Fill the gap and Recovery inputs: are the "MaxTradesAllowed" and "TradestoconstituteRecovery" parameters relative to each individual Timeframe or to the "pair" as a whole?

i.e: if TradesToConstituteRecovery=3 and I have 2 M1 buys and 1 M5 buy for a specific pair, am I already in recovery mode? or only when I get to 3 M1 buys will I be in recovery mode specifically for those 3 M1 buy trades?

Same question would apply for the max trades, is it per timeframe or per pair?

Thanks beforehand for the clarification

Diego
I wrote a detailed reply, copied stuff from the updated user guide, formatted it neatly, viewed the preview, forgot to actually submit and lost the lot. I am not going to do so again. I have updated the user guide after checking for clarity after reading your post. Download it for details.

: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.
User avatar
woodlands
Trader
Posts: 226
Joined: Sun Mar 23, 2014 6:16 pm

Peaky on Steroids

Post by woodlands »

I have M5 and M15 set as 'false' for the swap option to try and catch the retraces on my H1 and H4 'positive only' trades and have EURGBP taking a 5min opposite position while the H1 is in DD....... :yahoo:
EURGBPM5.png
This is fantastic in the truest sense, I am selecting pairs by CJ analysis and then entering in the 'pairs to trade' line
Thanks Steve :hi:
You do not have the required permissions to view the files attached to this post.
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.

Peaky on Steroids

Post by SteveHopwood »

woodlands » Tue Jul 04, 2017 6:15 pm wrote:I have M5 and M15 set as 'false' for the swap option to try and catch the retraces on my H1 and H4 'positive only' trades and have EURGBP taking a 5min opposite position while the H1 is in DD....... :yahoo:

Exactly the sort of thingy I had in mind when I conceived the bot. :clap: :clap: :clap:

: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.
Post Reply

Return to “Peaky forum”