MA
This is trickier to work out cos of the Time method.
IMHO, you should use the first tick of a new M15 bar to look at the last and last but one periods, so...
OTTOMH...
//---- input parameters extern double TakeProfit=8.0; extern double Lots=1.0; extern double StopLoss=5.0; static int numpos; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() //Definition des variables a utiliser { double RVIcurrent, RVIprevious, SRVIcurrent, SRVIprevious; bool SellCrossing, BuyCrossing, New15mnBar, NoPositions; SellCrossing=false; BuyCrossing=false; //----Set indicators to be used RVIcurrent=iRVI(NULL,PERIOD_M15,3,MODE_MAIN,1); SRVIcurrent=iRVI(NULL,PERIOD_M15,3,MODE_SIGNAL,1); RVIprevious=iRVI(NULL,PERIOD_M15,3,MODE_MAIN,2); SRVIprevious=iRVI(NULL,PERIOD_M15,3,MODE_SIGNAL,2); //SETTING CROSSING CONDITIONS if (RVIcurrent>=SRVIcurrent && RVIprevious<=SRVIprevious)BuyCrossing=true; else BuyCrossing=false; if (RVIcurrent<=SRVIcurrent && RVIprevious>=SRVIprevious)SellCrossing=true; else SellCrossing=false; //POSITIONS SHOULD ONLY BE OPEN ON OPENING OF 15 MN BARS if (Volume[0]=1) // Go for it on first tick of new bar { if(SellCrossing==true) { OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"H 15 min",12345,0,Red); PlaySound("alert.wav"); } if(BuyCrossing==true) { OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"H 15 min",12345,0,Green); PlaySound("alert.wav"); } } return(0); } //+------------------------------------------------------------------+The end
MA
This is trickier to work out cos of the Time method.
IMHO, you should use the first tick of a new M15 bar to look at the last and last but one periods, so...
OTTOMH...
Thank you BarrowBoy,
This make my code lighter and a bit more reliable indeed, but it does not solve the fact that the RVI crossing signal is only working 70% of the time.....
Can you point me to the right direction in order to handle this ? Should I create an array and stock bar values in it then make comparaison between them ?
MA
Keep it simple - debug this code, dont add complexity without purpose.
--
Try
(RVIcurrent>SRVIcurrent && RVIprevious<=SRVIprevious) (RVIcurrent<SRVIcurrent && RVIprevious>=SRVIprevious)
--
if no improvement, look at the Journal for OrderSend errors
If no order errors add a print statement when BuyCrossing & SellCrossing are set to true, and Print just before OrderSend. If the 'true prints' & the 'order send prints dont match
-BB-
MA
Keep it simple - debug this code, dont add complexity without purpose.
--
Try
--
if no improvement, look at the Journal for OrderSend errors
If no order errors add a print statement when BuyCrossing & SellCrossing are set to true, and Print just before OrderSend. If the 'true prints' & the 'order send prints dont match
-BB-
Thank you very much for your help again, I am going to try all that.
I'm not sure I trust the "if(Volume[0] ==1) part... have never watched it...
Set an alert, see if it always happens...
.
.
//POSITIONS SHOULD ONLY BE OPEN ON OPENING OF 15 MN BARS
if(Volume[0] == 1) Alert("Volume = 1 at ", detected at TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES); // add this
if (Volume[0]=1) // Go for it on first tick of new bar
I see an error in your code...
if (Volume[0]=1) // Go for it on first tick of new bar
should be
if (Volume[0]==1) // Go for it on first tick of new bar
I see an error in your code...
if (Volume[0]=1) // Go for it on first tick of new bar
should be
if (Volume[0]==1) // Go for it on first tick of new bar
The editor poped up an error message for the if(Volume[0]=1) and I corrected it anyway. Looks like this formula is working the same way than the one I initially used - so work fine for less amount of code.
Still have to tweak my damned crossing formula to make it catch all signals.
Good weekend
MovingAverage
MA
Keep it simple - debug this code, dont add complexity without purpose.
--
Try
--
if no improvement, look at the Journal for OrderSend errors
If no order errors add a print statement when BuyCrossing & SellCrossing are set to true, and Print just before OrderSend. If the 'true prints' & the 'order send prints dont match
-BB-
Just to add a final line about this, I had missed the part where you added the part
RVIcurrent=iRVI(NULL,PERIOD_M15,3,MODE_MAIN,1);
SRVIcurrent=iRVI(NULL,PERIOD_M15,3,MODE_SIGNAL,1);
RVIprevious=iRVI(NULL,PERIOD_M15,3,MODE_MAIN,2);
SRVIprevious=iRVI(NULL,PERIOD_M15,3,MODE_SIGNAL,2);
and in fact it solved my problem ! next time I should look more carefully to the answer, didnt catch you modified those line the first time.
Thx i have now something working properly.
Regards,
MovingAverage
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi again,
First of all I appologize for flooding the forum with so much help requests, but I am almost done.....so please help one more time.
I have coded a simple crossing EA, unfortunatly it is missing about 35% of the crossing signals....I tried to be simple while coding it but looks like I may have missed something or that my coding is sub optimal. Please check below code and give advice.:
thx for your attention.
Movingaverage