Can anyone tell me what I am doing wrong? - page 2

 

I'm working this out now. I want it to close a short position when either the CCI crosses above 100 or above -100. Earlier I had success with using if(OrdersTotal()==0) to keep it from opening a million trades and I am thinking once I get the ticket error figured out the below code will work?  


if((PreviousCCIReading < 100  && CurrentCCIReading > 100) || (PreviousCCIReading < -100  && CurrentCCIReading > -100))

if(OrdersTotal()==1)
OrderClose(1234,LotSize,Bid,3,Red);
 
GrumpyDuckMan:

Just add this to the top of your code

In this way the complier will tell you the error line of code. If you encounter a warning, or error description of a (string to int). You have a variable that can not be of the same type. 

Thank you

 
Vincent Capizzo:
if(OrdersTotal()==1)
OrderClose(1234,LotSize,Bid,3,Red);
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
          Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
          MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
 
William Roeder:
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
          Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
          MagicNumber: "Magic" Identifier of the Order - MQL4 Articles

I've replaced the code as follows and will get back to it tomorrow. 


global has "extern int MagicNumber = 1234;"

void Ontick has "OrderClose(MagicNumber,LotSize,Bid,3,Red);" 


I'm assuming I need to use an order select function

 
Vincent Capizzo: void Ontick has "OrderClose(MagicNumber,LotSize,Bid,3,Red);"

Perhaps you should read the manual. What is the first argument to OrderClose?

Perhaps you should read the links provided, where they show a filtered OrderSelect loop.

Reason: