Need help with coding using history values - page 3

 
atomi50:

no guess work, but learning. Again,I am not a programmer,but one day I will get better at it



Can you tell me how would I count the losses in history for a selected currency pair?

if I have 3 losses for one pair and I want to sum them,how would I do that?

If you look at my code, you have a loop which selects each order in you history in turn.

Then if that order a) is of the same pair as the chart and b) was created in the current day you "do stuff".

In your case you need to add the value returned by OrderProfit() to a variable.

Please read the documentation section in this forum and start to annotate the code that I've given you for this, so that you know exactly what it is doing. Its really not as hard as you are making it.

 
cloudbreaker:

If you look at my code, you have a loop which selects each order in you history in turn.

Then if that order a) is of the same pair as the chart and b) was created in the current day you "do stuff".

In your case you need to add the value returned by OrderProfit() to a variable.

Please read the documentation section in this forum and start to annotate the code that I've given you for this, so that you know exactly what it is doing. Its really not as hard as you are making it.

I know what you mean man and I am trying but please understand that I never coded anything and programming is not the easiest thing in the world for me right now.


if I want to add loss to take profit is it ok if I put


if(OrderProfit()<=0)

}

status=TakeProfit+OrderProfit(); // or do I have to put - since the value is negative for losses?

Print(" Loss ", OrderSymbol() );

}

else

...

 
atomi50:

I know what you mean man and I am trying but please understand that I never coded anything and programming is not the easiest thing in the world for me right now.


if I want to add loss to take profit is it ok if I put


if(OrderProfit()<=0)

}

status=TakeProfit+OrderProfit(); // or do I have to put - since the value is negative for losses?

Print(" Loss ", OrderSymbol() );

}

else

...


OrderProfit() would have to be < 0 before you'd want to flag a loss. If it equals zero, you'll have had a flat day.

I'm a bit concerned that you are including a variable called TakeProfit in a calculation of profits, as I'd expect a variable with that name to be a relative value in pips or an absolute price.

In the maths, just add OrderProfit() as it will return a negative double for a loss.

If it were me I'd be saying:


double myTotal = 0;

...

...

... then in the loop where you've found an order that you regard to be relevant ...

myTotal = myTotal + OrderProfit();

if (OrderProfit() >= 0)

 Print("We made a PROFIT of ",DoubleToStr(OrderProfit(),2)," today on the ",Symbol()," pair");

else

 Print("We made a LOSS of ",DoubleToStr(OrderProfit(),2)," today on the ",Symbol()," pair");


Please start NOW to use the Documentation, lots of Print() statements and good old trial and error rather than asking me every little thing and having me write your EA by stealth. You will learn a lot more if you do it my way mate.

Enough already!

 
cloudbreaker:

OrderProfit() would have to be < 0 before you'd want to flag a loss. If it equals zero, you'll have had a flat day.

I'm a bit concerned that you are including a variable called TakeProfit in a calculation of profits, as I'd expect a variable with that name to be a relative value in pips or an absolute price.

In the maths, just add OrderProfit() as it will return a negative double for a loss.

If it were me I'd be saying:


double myTotal = 0;

...

...

... then in the loop where you've found an order that you regard to be relevant ...

myTotal = myTotal + OrderProfit();

if (OrderProfit() >= 0)

Print("We made a PROFIT of ",DoubleToStr(OrderProfit(),2)," today on the ",Symbol()," pair");

else

Print("We made a LOSS of ",DoubleToStr(OrderProfit(),2)," today on the ",Symbol()," pair");


Please start NOW to use the Documentation, lots of Print() statements and good old trial and error rather than asking me every little thing and having me write your EA by stealth. You will learn a lot more if you do it my way mate.

Enough already!

K one more post just to say thank you CB :)

 
atomi50:

K one more post just to say thank you CB :)

Its a pleasure. Have fun.

If you do have any further problems (and you can't find the answer by searching the documentation, or other posts) feel free to drop me a PM to prompt me to look at your new thread.

Reason: