does it enter trades when you comment
//if(OpenOrdersThisPair(Symbol())==0)does it enter when
LotSize = 0.1;
etc. work your way back till it starts entering trades, once there you will probably know what the problem is. hth
Yea it enters on the long side even with lot size "0"...
Changing the OpenOrderThisPair doesnt work either.... Hmmm. It's very strange...
Changing the OpenOrderThisPair doesnt work either.... Hmmm. It's very strange...
DomGilberto:
Yea it enters on the long side even with lot size "0"...
Changing the OpenOrderThisPair doesnt work either.... Hmmm. It's very strange...
Yea it enters on the long side even with lot size "0"...
Changing the OpenOrderThisPair doesnt work either.... Hmmm. It's very strange...
If this test returns non zero . . .
if(OpenOrdersThisPair(Symbol()) == 0)
. . . the OrderSend() is not called, but you still check if SellTicketOrder is greater than 0 . . .
Do this . . .
if (direction==1)//--Sell--// { { double ssl=sell_stop_price; double stp=sell_takeprofit_price; LotSize = (RiskedAmount/(pips_to_ssl/pips))/10; if(OpenOrdersThisPair(Symbol())==0) { int SellTicketOrder = OrderSend(Symbol(),OP_SELLSTOP,LotSize,sellPrice,3,ssl,stp,NULL,MagicNumber,0,Red); if(SellTicketOrder > 0) { Print("Order Placed #", SellTicketOrder); } else { Print("Order Send Failed, error # ", GetLastError()); } } }
Nope - doesn't seem to want to send the sell order...
It must be an error in the way I wrote the code regarding the "IF" statements within the for loop that sends the OrderEntry function to trigger an order...
It must be an error in the way I wrote the code regarding the "IF" statements within the for loop that sends the OrderEntry function to trigger an order...
DomGilberto:
Nope - doesn't seem to want to send the sell order...
It must be an error in the way I wrote the code regarding the "IF" statements within the for loop that sends the OrderEntry function to trigger an order...
So what error do you get now ? if you don't get one and you don't get "Order placed # 12345" then the OrderSend() isn't being called and you have an issue with your OpenOrdersThisPair() function . . . post your code.
Nope - doesn't seem to want to send the sell order...
It must be an error in the way I wrote the code regarding the "IF" statements within the for loop that sends the OrderEntry function to trigger an order...
When this runs, it works fine for the long side(I have just been playing around with this for the past 2 hours now). Thing is, I will most likely wind you and a certain somebody up, as I know where I am going wrong (where I call "CheckForMaTrade" function) with regards to the IF statements relative to the moving average parameters, and how if they are "true" it will send OrderEntry to OrderSend... Problem is, I am still learning how to write that part properly...
//+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- if(OpenOrdersThisPair(Symbol())>=1) { if(UseMoveToBreakEven)MoveToBreakEven(); if(UseTrailingStop)AdjustTrail(); if(Use_MA_Trail)MA_Trail(); } if(IsNewCandle())CheckForMaTradeLong(); if(IsNewCandle())CheckForMaTradeShort(); //---- return(0); }
DomGilberto:
When this runs, it works fine for the long side(I have just been playing around with this for the past 2 hours now). Thing is, I will most likely wind you and a certain somebody up, as I know where I am going wrong (where I call "CheckForMaTrade" function) with regards to the IF statements relative to the moving average parameters, and how if they are "true" it will send OrderEntry to OrderSend... Problem is, I am still learning how to write that part properly...
When this runs, it works fine for the long side(I have just been playing around with this for the past 2 hours now). Thing is, I will most likely wind you and a certain somebody up, as I know where I am going wrong (where I call "CheckForMaTrade" function) with regards to the IF statements relative to the moving average parameters, and how if they are "true" it will send OrderEntry to OrderSend... Problem is, I am still learning how to write that part properly...
RaptorUK:
So what error do you get now ? if you don't get one and you don't get "Order placed # 12345" then the OrderSend() isn't being called and you have an issue with your OpenOrdersThisPair() function . . . post your code.
So what error do you get now ? if you don't get one and you don't get "Order placed # 12345" then the OrderSend() isn't being called and you have an issue with your OpenOrdersThisPair() function . . . post your code.
So .. . . what error do you get, etc . . .
Oh sorry - I am no longer getting any error what so ever. I am getting just buy orders going through and no sell orders...
It's in relation to my previous thread regarding MA cross overs - I still don't get it! But I don't want to wind anyone up and beat a dead horse whilst people are giving me the answer (although I dont understand the answer lol)! Cheers RaptorUK for your help!
It's in relation to my previous thread regarding MA cross overs - I still don't get it! But I don't want to wind anyone up and beat a dead horse whilst people are giving me the answer (although I dont understand the answer lol)! Cheers RaptorUK for your help!
if(IsNewCandle())CheckForMaTradeLong(); if(IsNewCandle())CheckForMaTradeShort();While I support factoring operations into functions, I don't for most variations of New Candle/New Bar because that function can only be called ONCE [per start()]
int start(){ static datetime time0; bool isNewCandle = time0 != Time[0]; time0 = Time[0]; // Once per start only. : if(isNewCandle)CheckForMaTradeLong(); if(isNewCandle)CheckForMaTradeShort();
Thanks WHRoeder - good tip!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am struggling to understand why the long positions work and the short trades dont at all?
I have a feeling that it has something to do with my init function to determine the number of decimal places with the given broker at hand. (as this seems to be the culprit for why phantom orders are thrown out right at the beginning of when I first initiate the tester...)
Anyone have any ideas why the short side is telling me this error?
Thanks in advance (the code is a little messy at the moment, I intend on cleaning it up of course!)