How to code? - page 42

 
jimven:
Save the current bar's highest quoted value to a variable. Every time you get another quote, compare it with the value of the variable. If the new value is higher, save it to the variable. If the new value is lower, keep the variable the same.

if(variable < newquote)

variable = newquote;

Hope that helps!

Now that I think about it, your suggestion will probably work. Thank you! I'll try it out.

 
wolfe:
Now that I think about it, your suggestion will probably work. Thank you! I'll try it out.

Good. When the trade position is closed, you want to set the variable to zero. When the next trade opens, you start the process again.

Of course my example was for a "BUY" position. For "SELL," you want to get the lowest value saved.

 

Help with negative values ??

Could anyone share with what syntax and instructions I would use in mql to write some code in EA using the following:

(OrderProfit() < 0).

Except I really want to know when OrderProfit() is some specific value less than zero such as when the profit on an open trade is -1,250.00. For example:

if (OrderProfit() < -1,250.00).

Thanks

 
waaustin:
Could anyone share with what syntax and instructions I would use in mql to write some code in EA using the following:

(OrderProfit() < 0).

Except I really want to know when OrderProfit() is some specific value less than zero such as when the profit on an open trade is -1,250.00. For example:

if (OrderProfit() < -1,250.00).

Thanks

I think you have the right idea. However you would probably want to use if (OrderProfit() <= -1250.00) Your OrderProfit() may never = -1,250.00, especially if a position is held for more than a day and swaps are involved. I think you would be safer to use less than or equal (<=). You may want to set an external double variable so you can change the negative amount if you wish to. Such as external double Loss_Value = -1250.00; then you could use if (OrderProfit() <= Loss_Value).

Hope this helps

 

I Need Help

I am appealing to the experts out there to please come to my aid i need some to help me buld an EXPERT ADVISER META 4 TRADER for me i would be greatfull if my request is granted.

 
vonokpasah:
I am appealing to the experts out there to please come to my aid i need some to help me buld an EXPERT ADVISER META 4 TRADER for me i would be greatfull if my request is granted.

Hi vonokpasah,

Just for information: we are having few very good threads with templates to create EAs and indicators. For example:

Templates to create EAs and Indicators:

- some good templates are here;

- templates with some new codes are here.

- Programming Modules with many programming functions are here.

- function of "mql4 code": thread with codes.

To use those templates and to create your own EA so you will need some very preliminary knowledge and it is basicly related to this thread https://www.mql5.com/en/forum

If you don't want to do some routine coding so you may automate this job: use this EA builder Expert Advisor Builder for MetaTrader 4 (it is free) and use this program Forex Trading with Gordago Forex Broker - Best Forex Software for Creating Forex Trading System! (I bought it for $9 long time ago - don't know about the price now). But to use those builders so you will need this thread first with Codersguru lessans https://www.mql5.com/en/forum

 

Using variables in an EA

Remember that any time you store data to temporary variables in an EA, the data will be gone if you reinitialize or restart the EA (or reboot your computer). This could have unexpected consequences regarding your trades. One possibility is that open trades will close, for example.

You can store data to Global Variables (using GlobalVariableSet and GlobalVariableGet). They remain in the terminal for two weeks (I think), even if undisturbed by your EA. But of course such data could quickly become just as problematic as lost data if you have a computer equipment problem.

In any event, your EA should be written defensively to prepare for loss of connection and the possibility of reinitialization.

 
 

May be i understood the code above:

We can affect a value to smRsi because it use the same index then the iRsi().

Can someone confirm this ?

 

Flytox:

I cannot find such code in my copy of TrendStrength.

Files:
Reason: