How do I refer to a previous operation based on whether the result of the operation was positvo or negative?
I use this type of logic allot in my expert advisors. Here's one of my useful function.
int Sign(double Value){ if(Value<0){return(-1);} if(Value>0){return( 1);} }Generally speaking, you could have just asked if the OrderProfit<0 or OrderProfit>0 or OrderProfit==0. Using my function something like int Last_Order_Result_Sign=Sign(OrderProfit()); would suffice.
I use this type of logic allot in my expert advisors. Here's one of my useful function.
Generally speaking, you could have just asked if the OrderProfit<0 or OrderProfit>0 or OrderProfit==0. Using my function something like int Last_Order_Result_Sign=Sign(OrderProfit()); would suffice.Thanks ubzed.
you have many pips
Hello ubzen. which is the way to refer, not only to the last operation, but also to the penultimate and others? (that's my real intention)
Thanks Againg. I hope you can help me (this is killing me)
Trader201
Hello ubzen. which is the way to refer, not only to the last operation, but also to the penultimate and others? (that's my real intention)
Thanks Againg. I hope you can help me (this is killing me)
Trader201
OrderHistory is your freind in this case :-)
Hello EZDeveloper. Thank you for your help.
I understand that I can use OrderSelect for select previous trades. But, What I need to write in the code for make the reference to the previous position?
For example: in an indicator, I use numbers, like 0 for actual, 1 is one before, 2 is two before, and continues like this. Now, in the case for previous trades, What I need to write for said: before trade, 2 trade before, 3 trade before, and like this?
Thanks againg
Trader201
Hello EZDeveloper. Thank you for your help.
I understand that I can use OrderSelect for select previous trades. But, What I need to write in the code for make the reference to the previous position?
For example: in an indicator, I use numbers, like 0 for actual, 1 is one before, 2 is two before, and continues like this. Now, in the case for previous trades, What I need to write for said: before trade, 2 trade before, 3 trade before, and like this?
Thanks againg
Trader201
from moving average
//+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double LotsOptimized() { double lot=Lots; int orders=HistoryTotal(); // history orders total int losses=0; // number of losses orders without a break //---- select lot size lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1); //---- calcuulate number of losses orders without a break if(DecreaseFactor>0) { for(int i=orders-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; } if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue; //---- if(OrderProfit()>0) break; if(OrderProfit()<0) losses++; } if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1); } //---- return lot size if(lot<0.1) lot=0.1; return(lot); }Trie first something yourself with for example this so we can see what you do and how we can help
For getting what you want you can trie to change this ....
How do I refer to a previous operation, if you want the note based on whether the result of the operation was positvo or negative?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Example: if you want to say a condition like this:
if (previous trade was loser)
if (previous trade was winner)
if (previous trade was neutral)
Thanks a Lot
Trader201