Help with coding my strategy?

 

Hi to all.

I am a newbie to this forum.

But have been stumbling through trading since 2007.

I have had a few ea's programmed for me in the past and have made a few simple ones myself.

I've had a go at combining elements and the ea's have worked in the past.

I have been trading my strategy on 4 pairs with pretty small profits daily for the past 2 years.

What I would like to do is fully automate the manual process.

As I am loosing quite a few pips waiting for mt4 to accept the trade, close the window confirmation and re-open the next to place the trade.

I have most of my code done to cover the Lot size and the Hidden TP and SL.

But I have no idea of how to code the Order Entry according to the most important part.

I am looking for some code to look at the previous Hour Candle Close Direction.

And upon the close of the 11:00 Hour Candle.

Open a trade in the direction of the 11:00 Candle, upon the opening of the 12:00 Candle.

eg.

11:00 Hour Candle Closes is in a SELL Direction,

Open a trade to sell at the opening of the 12:00 candle.

Could some one please give me a guiding had with this, Please ?

Below is the code that I already have for the Hidden TP and SL and Time.

( This is for my pepperstone account, it is in 5 digits)

//+------------------------------------------------------------------+
 extern double Lots=2;
 extern bool use_hidden_stop_loss = true;
 extern int hidden_sl = 100;
 extern bool use_hidden_take_profit = true;
 extern int hidden_tp = 45;
 extern int Start_Time = 1200; // Time to allow trading to start ( hours of 24 hr clock )12:00
 extern int Finish_Time = 1201; // Time to stop trading ( hours of 24 hr clock ) 12:01

//+------------------------------------------------------------------+

void hidden_take_profit()
 {
 int totalorders = OrdersTotal();
 for(int i=totalorders-1;i>=0;i--)
 {
OrderSelect(i, SELECT_BY_POS);
 bool result = false;
 if ( OrderSymbol()==Symbol() )
 {
 if (OrderType() == OP_BUY && OrderOpenPrice()+hidden_tp*Point<=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
 if (OrderType() == OP_SELL && OrderOpenPrice()-hidden_tp*Point>=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );

 }
 }
 return;
 }
 //+-------------------------------------------------------------------------------------------+
 void hidden_stop_loss()
 {
 int totalorders = OrdersTotal();
 for(int i=totalorders-1;i>=0;i--)
 {
OrderSelect(i, SELECT_BY_POS);
 bool result = false;
 if ( OrderSymbol()==Symbol() )
 {
 if (OrderType() == OP_BUY && OrderOpenPrice()-hidden_sl*Point>=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
 if (OrderType() == OP_SELL && OrderOpenPrice()+hidden_sl*Point<=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );

 }
 }
 return;
 }
 //+-------------------------------------------------------------------------------------------+
 //| expert initialization function |
 //+-------------------------------------------------------------------------------------------+

int init()
 {
 //----

//----
 return(0);
 }

 //+-------------------------------------------------------------------------------------------+
 //| expert deinitialization function |
 //+-------------------------------------------------------------------------------------------+

int deinit()
 {
 //---- 

//----
 return(0);
 }

//+-------------------------------------------------------------------------------------------+
 //| expert start function |
 //+-------------------------------------------------------------------------------------------+

int start()
 {
 //----
 if (use_hidden_stop_loss) hidden_stop_loss();
 if (use_hidden_take_profit) hidden_take_profit();
 //----
 return(0);
 }


 //+-------------------------------------------------------------------------------------------+


I eagerly await you input.

P.S. I am also looking for a hedging function to possibly add to this strategy as well.

Kind regards,

bubba08

 

I did not read your code

Please use the SRC button to post code . . .

the idea in general

bool TradeAlreadyOpen;
if (TimeHour(Time[0]) == 12 && !TradeAlreadyOpen)
   {
   if (Close[1] > Open[1])
      {
      Buy...
      }
   }

work it out

 
qjol:

I did not read your code

Please use the SRC button to post code . . .

the idea in general

work it out

Sorry qjol:

Like I said I am a newbie to this forum.

I am still trying to get Tradestation Easylanguage out of my head, and try to get my head around some of the new stuff mt4 has changed to over the past few new releases.

Thank you for your reply and your input.

//+------------------------------------------------------------------+
 extern double Lots=2;
 extern bool use_hidden_stop_loss = true;
 extern int hidden_sl = 100;
 extern bool use_hidden_take_profit = true;
 extern int hidden_tp = 45;
 extern int Start_Time = 1200; // Time to allow trading to start ( hours of 24 hr clock )12:00
 extern int Finish_Time = 1201; // Time to stop trading ( hours of 24 hr clock ) 12:01

//+------------------------------------------------------------------+

void hidden_take_profit()
 {
 int totalorders = OrdersTotal();
 for(int i=totalorders-1;i>=0;i--)
 {
OrderSelect(i, SELECT_BY_POS);
 bool result = false;
 if ( OrderSymbol()==Symbol() )
 {
 if (OrderType() == OP_BUY && OrderOpenPrice()+hidden_tp*Point<=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
 if (OrderType() == OP_SELL && OrderOpenPrice()-hidden_tp*Point>=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );

 }
 }
 return;
 }
 //+-------------------------------------------------------------------------------------------+
 void hidden_stop_loss()
 {
 int totalorders = OrdersTotal();
 for(int i=totalorders-1;i>=0;i--)
 {
OrderSelect(i, SELECT_BY_POS);
 bool result = false;
 if ( OrderSymbol()==Symbol() )
 {
 if (OrderType() == OP_BUY && OrderOpenPrice()-hidden_sl*Point>=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
 if (OrderType() == OP_SELL && OrderOpenPrice()+hidden_sl*Point<=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );

 }
 }
 return;
 }
 //+-------------------------------------------------------------------------------------------+
 //| expert initialization function |
 //+-------------------------------------------------------------------------------------------+

int init()
 {
 //----

//----
 return(0);
 }

 //+-------------------------------------------------------------------------------------------+
 //| expert deinitialization function |
 //+-------------------------------------------------------------------------------------------+

int deinit()
 {
 //---- 

//----
 return(0);
 }

//+-------------------------------------------------------------------------------------------+
 //| expert start function |
 //+-------------------------------------------------------------------------------------------+

int start()
 {
 //----
 if (use_hidden_stop_loss) hidden_stop_loss();
 if (use_hidden_take_profit) hidden_take_profit();
 //----
 return(0);
 }


 //+-------------------------------------------------------------------------------------------+

Kind regards,

bubba08