Hello Everyone,
I am newbee in as EA developer, I am trying to create an EA which should take only trade per crossover ,,,Unfortunately I am not able to code the EA in such way as required, Its just taking trades all the way ... Pls can some one guide me through this . Orders are executing but EA should take one trade per cross over only.
Example if Bull Crossover then only one Trade of buy as same for sell.
Below is my piece of code FYR,
OrderSend: - Check your returned Value; if it succeeds, it will return the Ticket Number.
- 3 is too small as a Slippage input, Slippage is in points, not pips.
SignalCheck: - OrdersTotal should never return a negative number... why check if it's smaller then 0?
I did not run tests with your code but these are some points that should be addressed. Cheers!
OrderSend: - Check your returned Value; if it succeeds, it will return the Ticket Number.
- 3 is too small as a Slippage input, Slippage is in points, not pips.
SignalCheck: - OrdersTotal should never return a negative number... why check if it's smaller then 0?
I did not run tests with your code but these are some points that should be addressed. Cheers!
Hi..it is taking trades exactly how you code it...
if (rviMain > rviSignal && OrdersTotal() < 0)
this means that it will take long trades as long as rviM > rvi Sig... you did not code the crossover you can code crossover multiple ways...the easiest to explain is to think like that:
When is crossing over...how the lines looked before crossing and how they are looking now... which one was bigger before and which one is bigger now... what candle is "before" and what candle is "present" ... when do you take want to take the trade...on candle 0 ? or closing of last candle ??
also
if((Csell= true) && (SignalCheck() == false))
Csell = true ... this is assignment.... you assign to Csell value of true...you will have an error here ... "expression not Boolean" or something....
also ..
for (int i =OrdersTotal()-1;i>0;i--)
you are not counting all orders..
also... when use this
Ask+20*Point
Normalize it
Other then that the idea of your code is good...good luck
OrderSend(NULL,OP_BUY,0.01,Ask,3,Ask-50*Point,Ask+20*Point,"",12345);
-
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum (2020.07.25)
-
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).
-
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Everyone,
I am newbee in as EA developer, I am trying to create an EA which should take only trade per crossover ,,,Unfortunately I am not able to code the EA in such way as required, Its just taking trades all the way ... Pls can some one guide me through this . Orders are executing but EA should take one trade per cross over only.
Example if Bull Crossover then only one Trade of buy as same for sell.
Below is my piece of code FYR,