I've created an EA which is supposed to open trades base on RSI values and should work on 15min time frame. But it doesn't recognize the 3AM candle on everyday so doesn't open any trade. I appreciate if someone kindly debug this code for me.
If the RSI is above 50 at 3:00AM ET (15Min. candle close), it should open a Pending Buy 10 PIPs above the High of past 40 candles, and if the RSI is below 50 at 3:00AM ET (15Min. candle close), it should open a Pending Sell 10 PIPs below the Low of past 40 candles. Also it should close the trade at 11 AM ET.
Below is the code:
How do you know that it is not recognising the time?
Are you checking the log?
You cannot usually open a BuyStop at the current price, your SL and TP make no sense at all, Stop and Limit are lkely to be 1.xxxx, why are you multiplinh them by Point?
Hi Keith ,
Thanks for looking into my EA.
Back to your question, I didn't check the log but when I ran the EA, no order been opened.
About BuyStop, you're right, I forgot to add 10 PIPS to the current price. Also could you please amend the SL and TP the way you think is right?
That gets the high of the past 41 candles, not 40.
I assume that your entry is intended to besomething like
If the order is opened, why do youi then try to modify it with the same values?
That gets the high of the past 41 candles, not 40. You're correct, that was a typo.
If the order is opened, why do youi then try to modify it with the same values? I tried the syntax you are mentioning at first place but it didn't work, so I tried to modify the order with the same values.
I think that I made a typo
double TP = ??; ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,Stop,3,Limit,TP,NULL,16003,0,Green);
/Limit= boxlow-0.0010-MaxRisk; //Why are you deducting MaxRisk?????? Cause I would like to have 1 to 1 profit (TP=Risk) also I don't wanna risk more than 150 PIPs.
By doing that you are risking more than 150 pips
Keith, do you know why my EA doesn't recognize the 3:00 AM candle?
I even inserted a line to draw a vertical line at 3:00 AM everyday, but the EA draws the line only at the first day 3:00AM.
I haven't looked through all your code (or indeed this thread) but:
1. Give each line you create a unique name. The first line will be called "box"... but that is the same name your code will try to use for subsequent lines too. I suggest adding the datetime into the name.
2. Will this code snippet be called more than once in an hour? If this code gets called every tick, think about how many times it is going to try to create a 3AM line.
Hope that helps
Could you please do me a favor and give me a line of code which can find the 3AM candle (in 15 Min. time frame) for each day?
Thanks in advance.
OnCalculate/OnTick note if in an EA there will be no lines displayed until a tick is received