| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Need to help with "tradehour" https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3161 |
Page 1 of 2 |
| Author: | ROOI [ Sat Sep 21, 2013 10:52 am ] |
| Post subject: | Need to help with "tradehour" |
Hi Im trying to add to this code a set number to the "tradehour" and "trademinutes" and then create multiple blocks of these code to have different time for the EA to open trades. Here is the code Code: Select all |
|
| Author: | ROOI [ Sat Sep 21, 2013 11:02 am ] |
| Post subject: | Re: Need to help with "tradehour" |
At the moment the "tradehour" and trademin" can only equal one specific time. extern int TradeHour= 0; extern int TradeMinutes= 0; and // Buy criteria if ((TradeHour==Hour())&&(TradeMinutes==Minute())) //Signal Buy { int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"time trader buy order ",BuyMagicNumber,0,Blue); if(openbuy<1){int buyfail=1;} } }// halt1 if((halt2!=1)&&(AllowSell==true)){// halt2 RefreshRates(); // Sell criteria if ((TradeHour==Hour())&&(TradeMinutes==Minute())) //Signal Sell { int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"time trader sell order ",SellMagicNumber,0,Green); if(opensell<1){int sellfail=1;} } }// halt2 So what I want to know is if I will be able to set multiple times in the code. For example how can I add to the code "tradehours" and "trademinutes" in the buy and sell criteria and not have the error that the tradehour has been defined.There must be a simple way to be able for the EA to check the multiple buy/sell criteria with different values. Can anyone help me please.... |
|
| Author: | ROOI [ Sat Sep 21, 2013 11:06 am ] |
| Post subject: | Re: Need to help with "tradehour" |
am I at least trying to change the correct bit of code in the EA? |
|
| Author: | dietcoke [ Sun Sep 22, 2013 9:57 am ] |
| Post subject: | Re: Need to help with "tradehour" |
The easiest, but least elegant way to do this would be to have a separate extern variable for each hour and minute you want to trade at eg Code: Select all you then need to include the new variables in you trade open test eg: Code: Select all Obviously, this becomes an issue if you want to use lots of different possible entry times. In that case you will have to significantly rewrite your code to hold the trade times in an array which you loop through and test for each time in turn |
|
| Author: | fxdaytrader [ Sun Sep 22, 2013 10:43 am ] |
| Post subject: | Re: Need to help with "tradehour" |
In another thread you asked the same question, I suggested to use Steves tradinghour-code, I think it should work well, if you set the difference between start and end-hour to one minute (in the external variable, for example: +07:00,-07:01 I have added Steves/Baludas tradingtime-checking stuff to the EA. I spotted further that there are two variables (halt1,halt2) in the ea, but they never get resetted if once set to 1. I think this is a bloop, because if there are no open trades the halt1,halt2 variables should be set to 0 again ... See attached ... |
|
| Author: | ROOI [ Mon Sep 23, 2013 7:28 am ] |
| Post subject: | Re: Need to help with "tradehour" |
Thanks fort he help guys.Will have a look at.You have been a great help already |
|
| Author: | ROOI [ Mon Sep 23, 2013 4:07 pm ] |
| Post subject: | Re: Need to help with "tradehour" |
Hi Thanks again for your help.You have been generous.I have added in the times like you said but nothing happens at the times specified.(I want it to open a hedged order) Please let me now if there is something I else I need to do or can try to do. Once again.Thanks for your effort. |
|
| Author: | ROOI [ Mon Sep 23, 2013 4:17 pm ] |
| Post subject: | Re: Need to help with "tradehour" |
Hi so I have added the code as follows : Code: Select all When I compile it gives 4 errors : 'TradeHour1' - variable not defined D:\alpri demo indice\experts\time trader.mq4 (84, 55) 'TradeMinutes1' - variable not defined D:\alpri demo indice\experts\time trader.mq4 (84, 75) 'TradeHour1' - variable not defined D:\alpri demo indice\experts\time trader.mq4 (98, 56) 'TradeMinutes1' - variable not defined D:\alpri demo indice\experts\time trader.mq4 (98, 76) Please help as to where I can put the lines of code. Thanks very much for your time and energy in replying to noob like me |
|
| Author: | fxdaytrader [ Mon Sep 23, 2013 4:28 pm ] |
| Post subject: | Re: Need to help with "tradehour" |
I do not know what you are doing, but it works. Maybe you did some errors when inserting the tradingtimes, I added an example. And that works, tested some minutes ago with trading +19.19,-19.20 (insert your local time) .... What maybe not works is the tp/sl setting (during my test I commentet that out and replaced by a print-call) ... So, you asked for help regarding the tradingtimes-stuff. That is done because it is working. For your other problems (and there are some, I am sure) you should open a new thread or ask new questions See attached |
|
| Author: | ROOI [ Mon Sep 23, 2013 4:44 pm ] |
| Post subject: | Re: Need to help with "tradehour" |
HI Yip.Got it to open trades.Works well.The problem is it open a hedge trade every tic for that minute that is "trading hours" are on.So its like a little to many stacked orders. IS there anyway to change that it executes once per trading interval ? Once again thanks for the help.You guy are really helping me understand a scratch of the surface of you guys do. |
|
| All times are UTC | Page 1 of 2 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|