Holy Graily GTWV

Post Reply
User avatar
RisklessPips
Trader
Posts: 246
Joined: Mon May 09, 2016 2:24 pm
Location: Nairobi, Kenya

Holy Graily GTWV

Post by RisklessPips »

Possible Holy Graily GTWV ?

Context

I am currently manually switching setfiles for GTWV EA based on changing market conditions as and when I manually recognise the changes.

HGI is a superstar in recognising those changes so would it be possible to integrate HGI Signals into GTWV processing as follows.

GTWV to take HGI signals, apply an alternative set of predefined variables and carry on processing thereby releasing the user from manual setfile changes?

Specification

Return HGI Signals at set intervals

If Last HGI signal is a big (Trend) arrow
Apply the user defined BE/Trails under trend processing for existing trades
Apply the user defined SL/TP/BE/Trails under trend processing for new trades the EA may open

If last HGI signal is a RAD arrow
As above but use the settings saved under RAD processing

If last HGI signal is a RANGE arrow
As above but use the settings saved under RANGE processing

In all other cases use the settings saved under Standard processing

A Boolean to switch this processing off and just use standard settings.

End of specification

Explanation of logic above.

Trend arrows in HGI represent my momementum setfile
RAD Arrows represent a combination of my standard and momentum setfiles
RANGE Arrows represent my choppy setfiles

This code amendment would take HGI Signals and apply predetermined BE/SL/TP and trails to suit different price conditions automatically.

Thanks

Charles
Trading is a mind game - good job I have a brain
User avatar
TraderJoeForex
Trader
Posts: 1157
Joined: Fri Mar 08, 2013 10:29 pm
Location: South London

Holy Graily GTWV

Post by TraderJoeForex »

This is getting very interesting... :good:
User avatar
RisklessPips
Trader
Posts: 246
Joined: Mon May 09, 2016 2:24 pm
Location: Nairobi, Kenya

Holy Graily GTWV

Post by RisklessPips »

Holy Graily GTWV - development code

I've started making changes to GTWV to include HGI signals as indicators of changing market conditions.

I am not a coder of much worth :oops: so any help will be much appreciated - here is what I have done to the GTWV code so far.

1) I have added the extern variables required to process Trending, RAD and Range signals. The old variables are still in place as a default.

2) The new Extern variables relate to BE / SL / TP and Trails. (All the other processing is standard regardless of market conditions.)

3) I have added a boolean to check if HGI Signal processing is required by the trader.

4) In each of the functions for processing BE / SL / TP and Trails I have added a check to see if HGI signals processing is switched on.

a) if not - the current processing is allowed to continue
b) if HGI signals are required - the current variable values will be replaced by appropriate ones that relate to the most recent HGI signal and settings for that signal as saved by the user

Help required to move forward

a) How do I incorporate calls to hgi_lib so that these are made at periodic intervals for all traded symbols returning the most recent signal for each symbol. (As soon as a signal is found current candle going backwards that is what I want to use)

b) Once the symbols latest signal is identified, this is then required to trigger the use of the values saved for that signal in the processing functions above.

I attach the code I am changing for reference purposes.

Thanks

Charles
GTWV HGI Test.mq4
You do not have the required permissions to view the files attached to this post.
Trading is a mind game - good job I have a brain
User avatar
RisklessPips
Trader
Posts: 246
Joined: Mon May 09, 2016 2:24 pm
Location: Nairobi, Kenya

Holy Graily GTWV

Post by RisklessPips »

I am using the code below to open new seeds at TP and SL in GTWV.

This code works perfectly - except not 100% of the time (on the spot I'd say it opens a new trade 80% of the time because it fails one or other of the conditionals !)

The problem lies in the conditional statements that I am using to identify a closed trade and whether or not it is TP or SL and also in the time comparison conditional to ensure the trade has just been closed.

This code is in the OnTimer event

Can someone please help me to tighten this up so that it opens a new trade on SL or TP closer to 100% of the time ?

Code: Select all

  if ( (UseTpSeed) ||  (UseSlSeed)) // if user has selected add a new trade on previous closing out at SL or in profit.
 {
   
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
     if (UseTpSeed)
   {

     if((MathAbs(OrderClosePrice() - OrderTakeProfit()) < MathAbs(OrderClosePrice() - OrderStopLoss())) && (StringFind( OrderComment(), "[tp]" ) >= 0 ) )
   {
     if(TimeCurrent() - OrderCloseTime()<=1) // Ensure the trade has just been closed - This check WILL fail from time to time preventing opening of a new trade - So be it !
     {
        Sleep(1750); // Allow price to diverge from ask and bid
        if(OrderType()==OP_BUY)
        {
            SendSingleTrade(OrderSymbol(), OP_BUY, TradeComment, Lot, ask, 0, 0, MagicNumber); // // on a TP send same direction trade
        } //  if(OrderType()==OP_BUY)
        else if(OrderType()==OP_SELL)
       {
         SendSingleTrade(OrderSymbol(), OP_SELL, TradeComment, Lot, bid, 0, 0, MagicNumber); // on a TP send same direction trade
        } // else if(OrderType()==OP_SELL)
      } //  if(TimeCurrent() - OrderCloseTime()==0)
    } // if(MathAbs(OrderClosePrice() - OrderTakeProfit()) < MathAbs(OrderClosePrice() - OrderStopLoss())) 
    } //     if (UseTpSeed)
    
    if (UseSlSeed)
   { 
     if((MathAbs(OrderClosePrice() - OrderTakeProfit()) > MathAbs(OrderClosePrice() - OrderStopLoss())) && (StringFind( OrderComment(), "[sl]" ) >= 0 ) )
     {
        if(TimeCurrent() - OrderCloseTime()<=1) // Ensure the trade has just been closed - This check WILL fail from time to time preventing opening of a new trade - So be it !
     {
        Sleep(1750); // Allow price to diverge from ask and bid
        if(OrderType()==OP_BUY && (OrderOpenPrice() > OrderClosePrice()))  // only open a contra if the buy closed at a price lower than open  i.e at SL below entry price (if trailing) or real SL if not trailing
        {
            SendSingleTrade(OrderSymbol(), OP_SELL, TradeComment, Lot, bid, 0, 0, MagicNumber); // on a SL send opposite direction trade
        } //  if(OrderType()==OP_BUY)        
        else if(OrderType()==OP_SELL  && (OrderOpenPrice() < OrderClosePrice())) // only open a contra if the sell closed at a price higher than open i.e at SL below entry price (if trailing) or real SL if not trailing
       {
         SendSingleTrade(OrderSymbol(), OP_BUY, TradeComment, Lot, ask, 0, 0, MagicNumber); // on a SL send opposite direction trade
        } //  else if(OrderType()==OP_SELL)
      } //  if(TimeCurrent() - OrderCloseTime()==0)
    } //  if(MathAbs(OrderClosePrice() - OrderTakeProfit()) > MathAbs(OrderClosePrice() - OrderStopLoss())) 
    } //    if (UseSlSeed)
  }  // if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
 }  //  if ( (UseTpSeed) ||  (UseSlSeed)) // if user has selected add a new trade on previous closing out at SL or in profit.
Thanks

Charles
Trading is a mind game - good job I have a brain
Post Reply

Return to “Coders Hangout”